Java examples for Swing:JLabel
Associating a Label with a Component
import javax.swing.JLabel; import javax.swing.JTextField; public class Main { public static void main(String[] argv) { JLabel label = new JLabel("Name:"); label.setDisplayedMnemonic('N'); //from w ww .j a va2 s. c om JTextField component = new JTextField(); label.setLabelFor(component); } }