Java JLabel set enabled state to false(disable JLabel)

Description

Java JLabel set enabled state to false(disable JLabel)


import javax.swing.JFrame;
import javax.swing.JLabel;

public class Main extends JFrame {

  public Main() {
    super("Link JLabel with JTextField");

    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JLabel nameLabel = new JLabel("Java demo from demo2s.com.");
    nameLabel.setEnabled(false);/*  w ww. j  a v  a  2 s . com*/

    add(nameLabel);

  }

  public static void main(String[] args) {
    Main frame = new Main();
    frame.pack();
    frame.setVisible(true);
  }
}



PreviousNext

Related