Disable a label in Java
Description
The following code shows how to disable a label.
Example
/*from w w w . j a v a 2 s . c om*/
import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.border.Border;
public class Main {
public static void main(String args[]) {
JFrame f = new JFrame("Label Demo");
f.setSize(200, 360);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label= new JLabel("Java2s.com");
label.setEnabled(false);
f.add(label);
f.setVisible(true);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Swing »
Java Tutorial »
Swing »