net.sf.doolin.gui.swing
Class MnemonicInfo

java.lang.Object
  extended by net.sf.doolin.gui.swing.MnemonicInfo

public class MnemonicInfo
extends Object

Computing of mnemonic information (character and index) from an encoded text. The mnemonic is indicated by a & character in the text. For example, E&xit defines x as a mnemonic for the Exit text.

Author:
Damien Coraboeuf

Constructor Summary
MnemonicInfo(String name)
          Constructor
 
Method Summary
 void configureAction(Action action)
          Configures an action with this mnemonic information
 void configureButton(AbstractButton button)
          Configures a button with the mnemonic
 void configureLabel(JLabel label)
          Configures a label with this mnemonic information
 char getMnemonic()
          Returns the mnemonic character
 int getMnemonicIndex()
          Returns the mnemonic index
protected  int getMnemonicIndex(String name)
          Returns the position of a valid & character.
 String getText()
          Text stripped from its mnemonic information
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MnemonicInfo

public MnemonicInfo(String name)
Constructor

Parameters:
name - Text
Method Detail

configureAction

public void configureAction(Action action)
Configures an action with this mnemonic information

Parameters:
action - Action to configure
See Also:
Action.putValue(String, Object), Action.NAME, Action.MNEMONIC_KEY, Action.DISPLAYED_MNEMONIC_INDEX_KEY

configureButton

public void configureButton(AbstractButton button)
Configures a button with the mnemonic

Parameters:
button - Button to configure
See Also:
AbstractButton.setText(String), AbstractButton.setMnemonic(char), AbstractButton.setDisplayedMnemonicIndex(int)

configureLabel

public void configureLabel(JLabel label)
Configures a label with this mnemonic information

Parameters:
label - Label to configure
See Also:
JLabel.setText(String), JLabel.setDisplayedMnemonicIndex(int)

getMnemonic

public char getMnemonic()
Returns the mnemonic character

Returns:
mnemonic character or 0 is not defined

getMnemonicIndex

public int getMnemonicIndex()
Returns the mnemonic index

Returns:
mnemonic index or -1 is not defined

getText

public String getText()
Text stripped from its mnemonic information

Returns:
Text

getMnemonicIndex

protected int getMnemonicIndex(String name)
Returns the position of a valid & character.

Parameters:
name - Text
Returns:
Position of the mnemonic


Copyright © 2011. All Rights Reserved.