JCheckBox
JCheckBox is a GUI component that allows users to make a binary choice: checked (true) or unchecked (false).Example:
Source Code:
private void btnShowActionPerformed(java.awt.event.ActionEvent evt) {
StringBuilder sb = new StringBuilder("You selected: ");
if (chkJava.isSelected()) {
sb.append("Java ");
}
if (chkPython.isSelected()) {
sb.append("Python ");
}
if (chkCpp.isSelected()) {
sb.append("C++ ");
}
lblResult.setText(sb.toString());
}
Result:
Watch the video:
Ebook: https://softkhpc.blogspot.com/2025/05/java-programming-ebooks.html

