Java JButton set enabled state to false(disable JButton)
import java.awt.FlowLayout; import javax.swing.JButton; import javax.swing.JFrame; public class Main extends JFrame { public Main() { super("JButton"); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new FlowLayout()); JButton closeButton1 = new JButton("Close"); closeButton1.setEnabled(false);/* w w w. ja v a 2 s .c om*/ getContentPane().add(closeButton1); } public static void main(String[] args) { Main frame = new Main(); frame.pack(); frame.setVisible(true); } }