 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to disable JCheckBox if not checked in Java
The following is an example to disable JCheckBox if not checked in Java:
Example
import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JCheckBox; import javax.swing.JOptionPane; public class SwingDemo {    public static void main(String[] args) {       JCheckBox checkBox = new JCheckBox("Demo", true);       checkBox.addActionListener(new ActionListener() {          public void actionPerformed(ActionEvent e) {             if (checkBox.isEnabled())                checkBox.setEnabled(false);             else                checkBox.setEnabled(true);          }       });       JOptionPane.showMessageDialog(null, checkBox);    } }  Output

Now, when you will uncheck the above checkbox, it will get disabled:

Advertisements
 