Sun Java Solaris Communities My SDN Account Join SDN
 
Code sample

Code Samples from the Java Developers Almanac 2000

 

Code Samples Index

These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms

Associating a Label with a Component

When a label is associated with a component, you should call setLabelFor() to make the association explicit and then set a mnemonic on the label. The associated component will get the focus when the mnemonic is activated.

    
 JLabel label = new JLabel("Name:");
 label.setDisplayedMnemonic('N');
 label.setLabelFor(component);
 
 

Examplets provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan.
Order this book from Amazon