The Artima Developer Community
Sponsored Link

Java Buzz Forum
The many lives of javax.swing.Action

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Danno Ferrin

Posts: 39
Nickname: shemnon
Registered: Jun, 2003

Danno Ferrin isn't the worst speler you've met, but he's not the best either.
The many lives of javax.swing.Action Posted: Nov 15, 2003 6:12 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Danno Ferrin.
Original Post: The many lives of javax.swing.Action
Feed Title: And They Shall Know Me By My Speling Errors
Feed URL: http://shemnon.com/speling/archives/cat_GUI.rdf
Feed Description: Danno Ferrin's Many Reasons he was a Comp Sci Major and not an English Major
Latest Java Buzz Posts
Latest Java Buzz Posts by Danno Ferrin
Latest Posts From And They Shall Know Me By My Speling Errors

Advertisement

Gregg Bolinger been using swing for a while mentioned in My Approach to Menu's in SWING about how he extends and uses the Swing action alot. After being buried deep in Swing for nearly two years now I have to concur: Actions are more importiant than you may initially think.

For the Swing code I've written at my job I use Actions to back the actions of menu items, toolbar buttons, popup menu items, some of the regular old buttons, and even handeling Drag and Drop actions too! (Since the drag and drop is another way to invoke a menu action I just wire in the call to the actions for a successful drop).

Like Gregg I've overloaded abstract action, but I've gone crazy with stuffing in the standard behavior. First I populate all of the action values from a resource bundle. This allows for easier I18n of the action and it also keeps a lot of the related actions visual looks in the same file. This is handy when someone decides they don't like the menu accelerators you've selected or that all of te Icons need to be re-done and stored in a differnt place Next I populate a large amount of standard information into the value cache of the action itself:

  • Name
  • Location in the Menu Bar (i.e. file/new/widget or help/about
  • Location in the Tool Bar
  • Location in standard Pop-up
  • Toggelable (creates checkbox menu item or toggle toolbar button)
  • Asynchronous (spins a thread for the action)
  • Icon (along with rollover and selected varients)
  • Tool Tip
  • Mnemonic
  • Accelerator

And that's just what I can remember early in the morning on a weekend. I also provide standard methods to get a menu item and toolbar button out of the action so I can handle things like the checkbox menu items and global options such as show/hide menu icons and tooltips. I also try and limit any code that does any user initiated actions to live in the action methods of these objects.

By doing this it keeps a lot of the non-gui code out of the gui and I can stress out about bizzare JTable behavior without tripping over a database call to delete a row.

Read: The many lives of javax.swing.Action

Topic: Series_60_MIDP_SDK_for_Symbian_OS_v_1_2_1 Previous Topic   Next Topic Topic: Groovy: Making Java More Funky

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use