Interface Mnemonicable

  • All Known Implementing Classes:
    JXTaskPane

    interface Mnemonicable
    An interface that describes an object that is capable of being accessed/used via a mnemonic keystroke.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int getDisplayedMnemonicIndex()
      Returns the character, as an index, that the look and feel should provide decoration for as representing the mnemonic character.
      int getMnemonic()
      Returns the keyboard mnemonic for this component.
      void setDisplayedMnemonicIndex​(int index)
      Provides a hint to the look and feel as to which character in the text should be decorated to represent the mnemonic.
      void setMnemonic​(int mnemonic)
      Sets the keyboard mnemonic on this component.
    • Method Detail

      • getMnemonic

        int getMnemonic()
        Returns the keyboard mnemonic for this component.
        Returns:
        the keyboard mnemonic
      • setMnemonic

        void setMnemonic​(int mnemonic)
        Sets the keyboard mnemonic on this component. The mnemonic is the key which when combined with the look and feel's mouseless modifier (usually Alt) will activate this component.

        A mnemonic must correspond to a single key on the keyboard and should be specified using one of the VK_XXX keycodes defined in java.awt.event.KeyEvent. Mnemonics are case-insensitive, therefore a key event with the corresponding keycode would cause the button to be activated whether or not the Shift modifier was pressed.

        Parameters:
        mnemonic - the key code which represents the mnemonic
        See Also:
        KeyEvent, setDisplayedMnemonicIndex(int)
      • getDisplayedMnemonicIndex

        int getDisplayedMnemonicIndex()
        Returns the character, as an index, that the look and feel should provide decoration for as representing the mnemonic character.
        Returns:
        index representing mnemonic character
        Since:
        1.4
        See Also:
        setDisplayedMnemonicIndex(int)
      • setDisplayedMnemonicIndex

        void setDisplayedMnemonicIndex​(int index)
                                throws java.lang.IllegalArgumentException
        Provides a hint to the look and feel as to which character in the text should be decorated to represent the mnemonic. Not all look and feels may support this. A value of -1 indicates either there is no mnemonic, the mnemonic character is not contained in the string, or the developer does not wish the mnemonic to be displayed.

        The value of this is updated as the properties relating to the mnemonic change (such as the mnemonic itself, the text...). You should only ever have to call this if you do not wish the default character to be underlined. For example, if the text was 'Save As', with a mnemonic of 'a', and you wanted the 'A' to be decorated, as 'Save As', you would have to invoke setDisplayedMnemonicIndex(5) after invoking setMnemonic(KeyEvent.VK_A).

        Parameters:
        index - Index into the String to underline
        Throws:
        java.lang.IllegalArgumentException - will be thrown if index is >= length of the text, or < -1
        Since:
        1.4
        See Also:
        getDisplayedMnemonicIndex()