setLabelFor « Component « Java Swing Q&A





1. setLabelFor() not working URGENT    coderanch.com

2. setLabelFor    coderanch.com

3. use of setLabelFor()    coderanch.com

Imagine a login dialog. You got a label saying "Username" and a text field where the user should input the username. You would typically use the JLabel#setDisplayedMnemonic to define say 'U'. Then you would use JLabel#setLabelFor(userNameField). After this, when the user hits Alt+U, the user name text field would gain the focus.