Slide 1
Slide 2
Slide 3

Check Box in java programming (V78)

No Comments

JCheckBox

JCheckBox
is a GUI component that allows users to make a binary choice: checked (true) or unchecked (false).
 

Example:


Source Code:

Copied!
    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

back to top