SimpleExample Demonstrates
- changing the Look and Feel
- JRadioButtons, ButtonGroup, and mnemonics
- setting up an ActionListener as an inner class
- creating an anonymous WindowAdapter, implementing WindowClosing
UML
Mnemonics
A mnemonic allows the user to activate a button by holding ALT + the assigned mnemonic character. Setting the mnemonic for a button is relatively simple, just call the the setMnemonic(char c) method.
Button b = new Button("Hello");
b.setMnemonic('h');
That's it, no other coding required. One thing that's nice, if you're in Metal Look and Feel and you a tool tip, any assigned mnemonic is appended to the tip as 'ALT+x' where 'x' = whatever characters been assigned.
ToolTip
The demo doesn't include tool tips (the text you see when the mouse is over the component) but assigning one is easy; just invoke the setToolTextTip(String) method.
b.setToolTextTip("The Hello button");
This will work for every component as the method is defined in JComponent (the superclass of all Swing components).
|