Source Code : Get or set the selection state of JCheckBox
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Get or set the selection state of JCheckBox
import java.awt.FlowLayout;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
public class CheckBoxState extends JFrame {
public CheckBoxState() {
setSize(300, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout(FlowLayout.LEFT));
JCheckBox checkBox = new JCheckBox("Check me!");
checkBox.setSelected(true);
boolean selected = checkBox.isSelected();
if (selected) {
System.out.println("Check box state is selected.");
} else {
System.out.println("Check box state is not selected.");
}
getContentPane().add(checkBox);
}
public static void main(String[] args) {
new CheckBoxState().setVisible(true);
}
}
Thank with us