JCheckBox myCheckbox = new JCheckBox("Enable feature"); myCheckbox.setEnabled(false);
JCheckBox myCheckbox = new JCheckBox("Enable feature"); if (userIsLoggedIn) { myCheckbox.setEnabled(true); } else { myCheckbox.setEnabled(false); }This code creates a new checkbox with the label "Enable feature" and enables or disables it based on whether the user is logged in. The package library for JCheckBox and other javax.swing components is javax.swing.