 |
Quick tabbedpane switching w/o sacrifying mnemonics
Posted by herkules on September 08, 2005 at 03:51 AM | Comments (6)
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).
Find the sourcecode here and a usage sample here.
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
I don't know which is the greater UI crime: tabs or multiple key strokes.
Posted by: tackline on September 08, 2005 at 07:10 AM
-
yeah ... but I'd be glad to learn whats better!
Posted by: herkules on September 08, 2005 at 07:30 AM
-
in the case of a smaller number of tabs i prefer alt-1 through alt-n;
it seems to be consistent with many other apps, including firefox.
Posted by: eitan on September 09, 2005 at 06:21 AM
-
yes, had that in another app ... unfortunately, for my current use-case ... 10 it not enough ... 20 neither ... horrible to be honest
Posted by: herkules on September 09, 2005 at 06:34 AM
-
Nice work. This sort of component would be great to add to SwingLabs/SwingX, in our utility toolkit. Come drop us a line on the mailing lists--http://jdnc.dev.java.net. Cheers Patrick
Posted by: pdoubleya on September 09, 2005 at 07:11 AM
-
It's a small thing, they can have it. But *only* if they finally fix my bug reported in JXTreeTable!
What comes to mind ... these close-buttons are still hard to do on the tabs. Maybe I can integrate them with the popup ... I'll see....
Posted by: herkules on September 09, 2005 at 08:41 AM
|