/* The program demonstrate a check box It has an initial box checked * */ import javax.swing.*; public class CheckBox extends JFrame { JCheckBox ice_cream, banana, ribs; JPanel panel; public CheckBox() { // Sets the title of the window setTitle("Check Bow Window"); // Sets the size of the window setSize(300, 400); // Sets the action when the window closes setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Creates a panel panel = new JPanel(); // Creates 3 check box with ice_cream initially checked ice_cream = new JCheckBox("Ice Cream", true); banana = new JCheckBox("Banana"); ribs = new JCheckBox("Ribs"); // Adds the check boxes to the panel panel.add(ice_cream); panel.add(banana); panel.add(ribs); // Adds the panel to the content pane add(panel); // Sets the window to be visible setVisible(true); } public static void main(String[] args) { new CheckBox(); } }