Package be.ugent.caagt.swirl.actions

Provides support for standard Swing actions.


Class Summary
ButtonFactory Provides various methods to create buttons from internationalized descriptions.
Description An object of this class describes caption, mnemonic and accelerator key of a GUI component.
ExtensionFileFilter Implements a Swing file filter that filters files on extensions.
FileAction Common (abstract) super class of FileOpenAction and FileSaveAction.
FileOpenAction Abstract super class for actions that allow files to be loaded.
FileSaveAction Abstract super class for actions that allow files to be saved.
HideWindow Action that makes a particular window invisible.
MenuButton Button for use in a menu.
MenuCheckBoxButton Check box button for use in a menu.
MenuRadioButton Radio button for use in a menu.
ShowWindow Action that makes a particular window visible (if it was not) and brings it to the front.
SimpleAction Abstract action (controller) based on an internationalized description.
SingleSelectionAction Simple action which selects a given index in a SingleSelectionModel.
ToolBarButton Button for use on a tool bar.
ToolBarToggleButton Button for use on a tool bar.

Package be.ugent.caagt.swirl.actions Description

Provides support for standard Swing actions. The package contains several classes that help with internationalization of actions and buttons. For most practical applications however, we suggest the use of the menu builder (MenuBuilder) which has built-in internationalization, and uses the classes from this package behind the scenes.

The package also includes some (abstract) implementations of general purpose actions:

Description objects

A description object combines caption, mnemonic and accelerator key of a button into a single string. For example, the description string
     Javadoc inde&x search [shift F1]
can be used to provide a button with the caption 'Javadoc index search', the mnemonic 'x' and the accelerator key shift-F1.

Description strings are typically retrieved from resource bundles, making internationalization of buttons and actions fairly straightforward.

In most cases buttons and menu items can most easily be internationalized using actions that extend SimpleAction or through one of the class methods of ButtonFactory.

Enhanced action support

This package also supports some additional action properties. To take advantage of these new properties, you cannot use the standard Swing button classes but need to use one of the following new classes provided by this package:

Sharing a toggle button model

The following example illustrates the use of the property SimpleAction.TOGGLE_BUTTON_MODEL to allow a check box menu item and a toggle button to share state: selecting one of them, automatically selects the other.
     Action action = new SomeAction (...);
     action.putValue (
            new JToggleButton.ToggleButtonModel ()
     MenuCheckBoxItem checkBox = new MenuCheckBoxItem (action);
     ToolBarToggleButton toggleButton = new ToolBarToggleButton (action);
The same technique can be used with radio buttons.

Note that if two 'button groups' need to be synchronised, only one of them needs to be put inside a ButtonGroup object. However, in this case classes SelectionGroup or GenericSelectionGroup often provide a better alternative. Two 'selection groups' that share the same selection model are always automatically synchronised, and then there is no need for the individual button models to be shared.