de.tkuhn.swing.actions
Class ActionUtils

java.lang.Object
  extended by de.tkuhn.swing.actions.ActionUtils

public class ActionUtils
extends java.lang.Object

This class is a repository for static functions that operate on Actions and help using Collections of Actions.

Version:
0.9.3
Author:
Tilmann Kuhn
See Also:
Action

Method Summary
static javax.swing.JMenu addAll(javax.swing.JMenu menu, java.util.Collection<javax.swing.Action> actions)
          Adds all Action objects in the given Collection to the given JMenu
static javax.swing.JToolBar addAll(javax.swing.JToolBar toolBar, java.util.Collection<javax.swing.Action> actions)
          Adds all Action objects in the given Collection to the given JToolBar
static ActionComponentFactory getMenuActionComponentFactory()
          Get the ActionComponentFactory usable for adding Actions to a JMenu.
static ActionComponentFactory getToolBarActionComponentFactory()
          Get the ActionComponentFactory usable for adding Actions to a JToolBar.
static javax.swing.JComponent registerAllKeys(javax.swing.JComponent component, java.util.Collection<javax.swing.Action> actions)
          Registers the key shortcuts of all Actions objects in the given Collection with the given JComponent.
static void setMenuActionComponentFactory(ActionComponentFactory factory)
          Set the ActionComponentFactory used when adding Actions to a JMenu.
static void setToolBarActionComponentFactory(ActionComponentFactory factory)
          Set the ActionComponentFactory used when adding Actions to a JToolBar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

registerAllKeys

public static javax.swing.JComponent registerAllKeys(javax.swing.JComponent component,
                                                     java.util.Collection<javax.swing.Action> actions)
Registers the key shortcuts of all Actions objects in the given Collection with the given JComponent. To achieve that the values of Action.ACTION_COMMAND_KEY and Action.ACCELERATOR_KEY are queried for every Action Then the key-shortcut is mapped with the command String as identifier in the InputMap of the component and the identifier is mapped with the Action in the ActionMap of the component.

Parameters:
component - the JComponent to map the key shortcuts with.
actions - a Collection that may contain some Actions.
Returns:
the same component

addAll

public static javax.swing.JToolBar addAll(javax.swing.JToolBar toolBar,
                                          java.util.Collection<javax.swing.Action> actions)
Adds all Action objects in the given Collection to the given JToolBar

Parameters:
toolBar - the toolbar to add the actions to
actions - a Collection that may contain some Actions.
Returns:
the same toolbar

addAll

public static javax.swing.JMenu addAll(javax.swing.JMenu menu,
                                       java.util.Collection<javax.swing.Action> actions)
Adds all Action objects in the given Collection to the given JMenu

Parameters:
menu - the menu to add the actions to
actions - a Collection that may contain some Actions.
Returns:
the same menu

setToolBarActionComponentFactory

public static void setToolBarActionComponentFactory(ActionComponentFactory factory)
Set the ActionComponentFactory used when adding Actions to a JToolBar.

Parameters:
factory - New value of property toolBarActionComponentFactory.

setMenuActionComponentFactory

public static void setMenuActionComponentFactory(ActionComponentFactory factory)
Set the ActionComponentFactory used when adding Actions to a JMenu.

Parameters:
factory - New value of property menuActionComponentFactory.

getToolBarActionComponentFactory

public static ActionComponentFactory getToolBarActionComponentFactory()
Get the ActionComponentFactory usable for adding Actions to a JToolBar.

Returns:
The ActionComponentFactory for JToolBars.

getMenuActionComponentFactory

public static ActionComponentFactory getMenuActionComponentFactory()
Get the ActionComponentFactory usable for adding Actions to a JMenu.

Returns:
The ActionComponentFactory for Menus.


Copyright © Tilmann Kuhn