Associating a Label with a Component
import javax.swing.JLabel; import javax.swing.JTextField; public class Main { public static void main(String[] argv) throws Exception { JTextField component = new JTextField(); JLabel label = new JLabel("Name:"); label.setDisplayedMnemonic('N'); label.setLabelFor(component); } }