com.mucommander.ui.helper
Class MnemonicHelper

java.lang.Object
  extended by com.mucommander.ui.helper.MnemonicHelper

public class MnemonicHelper
extends java.lang.Object

MnemonicHelper provides a way to easily set mnemonics to UI components, without having to bother with remembering which ones have already been assigned to another component.

To use it: simply create a new instance and keep calling getMnemonic(String) to get mnemonics from the giving pieces of text.

Author:
Maxence Bernard

Constructor Summary
MnemonicHelper()
          Creates a new blank MnemonicHelper.
 
Method Summary
 void clear()
          Clears any previously registered mnemonics by getMnemonic(String).
 char getMnemonic(javax.swing.JButton button)
          Convenience method that returns a mnemonic for the specified button.
 char getMnemonic(java.lang.String text)
          Finds and returns first character in the given string that's not already as a mnemonic.
 boolean isMnemonicUsed(char ch)
          Returns true if the specified character has already been previously used as a mnemonic, returned by getMnemonic(String).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MnemonicHelper

public MnemonicHelper()
Creates a new blank MnemonicHelper.

Method Detail

getMnemonic

public char getMnemonic(java.lang.String text)
Finds and returns first character in the given string that's not already as a mnemonic.

Returned mnemonic will be added to current internal list of taken mnemonics and won't ever be used again by this instance.

Parameters:
text - text to get a mnemonic from.
Returns:
the character to be used as a mnemonic, always in lower case, 0 if no mnemonic was available for this piece of text. 0 is returned if a null string is passed.

getMnemonic

public char getMnemonic(javax.swing.JButton button)
Convenience method that returns a mnemonic for the specified button. Yields to the same result as if getMnemonic(String) were called with JButton.getText().

Parameters:
button - the button to get a mnemonic for
Returns:
the character to be used as a mnemonic, always in lower case, 0 if no mnemonic was available for this piece of text. 0 is returned if a null string is passed.

isMnemonicUsed

public boolean isMnemonicUsed(char ch)
Returns true if the specified character has already been previously used as a mnemonic, returned by getMnemonic(String).

Parameters:
ch - the character which will be tested for an existing mnemonic.
Returns:
whether or not the character is already used in the mnemonics array.

clear

public void clear()
Clears any previously registered mnemonics by getMnemonic(String).



This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard