The Source for Java Technology Collaboration
User: Password:
Register | Login help    

Search

Online Books:
java.net on MarkMail:


Quick tabbedpane switching w/o sacrifying mnemonics

Posted by herkules on September 8, 2005 at 3:51 AM PDT
Having JTabbedPanes with many tabs can be awkward concerning keyboard usage. Per-tab mnemonics are not really an option because they really limit the number of available mnemonics for the tabs own valuable content!

Facing this problem, I created the TabSwitcher utility applicable to any JTabbedPane:
new TabSwitcher(tabbedpane, KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.ALT_DOWN_MASK));
TabSwitcher will automatically pop up when the given KeyStroke occurs on the JTabbedPane. It reflects the current number of tabs with their resp. titles and icons, computes a reasonable set of mnemonics and offers them as a JPopupMenu right at the position of the currently selected tab.

For the usage is mnemonic-like, I suggest to use an ALT-combination for the KeyStroke (Alt-T in my sample above).

screenshot


Find the sourcecode here and a usage sample here.
Related Topics >> Java Desktop      
Comments
Comments are listed in date ascending order (oldest first)