Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2004

Tip: Looking for answers? Try searching our database.

Texts on buttons aren't honored by Action

Thread view: 
hiwa - 05 Jan 2004 05:17 GMT
We make multiple buttons, e.g. [Joe], [Mary], [Paul], [Suzy], etc. And
when we set a same Action object to these buttons, button texts "Joe",
"Mary", etc. are all disappeared from the buttons' surfaces. This text
disappearing phenomenon occurs when we use only one button. It should
be needless to say that if we give a string to the Action's
constructor, all the buttons' got the same text string. That isn't
what we want. Action is a much handier object than Listener in Swing
framework, so we like to stick to using them. How could we solve this
problem?
Todd Corley - 05 Jan 2004 16:50 GMT
You have a major misconception on usage of Action.

One of the more common usage of Action is to share information
between a menu item and a tool bar button.  The Action allows
sharing resources (text, icon) and state in a single object that
can be used in multiple locations.

If you want to have different buttons perform the same action, just
create an action listener and add it to all the desired buttons.

Hope this helped,
Todd
Jon A. Cruz - 05 Jan 2004 19:23 GMT
>  It should
> be needless to say that if we give a string to the Action's
> constructor, all the buttons' got the same text string. That isn't
> what we want. Action is a much handier object than Listener in Swing
> framework, so we like to stick to using them. How could we solve this
> problem?

It could be more appropriate to use multiple Actions.

Or just change the text on the object after you create a JButton on
using that action.
hiwa - 06 Jan 2004 02:27 GMT
Thanks Todd and Jon.
Yes. It was my misconception about Action's functionality!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.