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);