Associating a Label with a Component - Java Swing

Java examples for Swing:JLabel

Description

Associating a Label with a Component

Demo Code

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

Related Tutorials