Java Swing How to - Disable a JLabel








Question

We would like to know how to disable a JLabel.

Answer

/*from www  .j a va2s . c o m*/
import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class Main {
  public static void main(String[] args) {
    JLabel label = new JLabel("java2s.com");
    label.setEnabled(false);
    
    JOptionPane.showMessageDialog(null, label);
    
  }
}