Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training

Creating Check Box in Java Swing

This section illustrates you how to create a Check Box component in Java Swing.

Ads

Tutorials   
Ads

Creating Check Box in Java Swing

     

This section illustrates you how to create a Check Box component in Java Swing.

In this section, you can learn simply creating the Check Box in Java Swing. Check Boxes are created in swing by creating the instance of the JCheckBox class using it's constructor which contains the string which has to be shown beside the check box on the frame or window like this:

Swing Check Box Component

This is written like:

JCheckBox chk = new JCheckBox("This is the Check Box");

This component of the javax.swing.*; is added to the frame using the add(component) method of the JFrame class.

Here is the code of the program:

import javax.swing.*;

public class CreateCheckBox{
  public static void main(String[] args){
  JFrame frame = new JFrame("Check Box Frame");
  JCheckBox chk = new JCheckBox("This is the Check Box");
  frame.add(chk);
  frame.setSize(400400);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setVisible(true);
  }
}

Download this example.

Advertisements

Share on Google+Share on Google+

Creating Check Box in Java Swing

Posted on: April 14, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Creating Check Box in Java Swing   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:3
ashish bhalodiya
October 15, 2012
types of checkboxes. and explain its diffrences

i hope give me reply fast
fred mwimike
November 28, 2012
java programming

am very interested in java programming
Nasir
April 16, 2015
Checkbox action

how can set column in table model select multiple checkbook in java swing

Ads

 

Ads