Create check box using JCheckBox

Source code below will show you, how to create a check box in java with text HI using JCheckBox.

***********************************************************************
COMPLETE SOURCE CODE FOR : CreateCheckBoxUsingJCheckBox.java
***********************************************************************


import javax.swing.JCheckBox;
import javax.swing.JFrame;

public class CreateCheckBoxUsingJCheckBox
{
public static void main(String[]args)
{
//Create check box with text HI
JCheckBox checkBox=new JCheckBox("HI");

//Create JFrame to place created JCheckBox
JFrame frame=new JFrame("Create check box using JCheckBox");

//add created check box into JFrame
frame.add(checkBox);

//set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//set JFrame size
frame.setSize(450,65);

//make your JFrame visible. So we can see it
frame.setVisible(true);
}
}


***********************************************************************
JUST COMPILE AND EXECUTE IT
***********************************************************************