What is Check Box?
A check box or tick box is a graphical user interface element that allow or permits user to make selections from the options. User can select more than one item or element.
The given example will explain you how to create check box in java swing. It is created in java by creating the instance of JCheckBo class. Here is the check box program :
public class CreateCheckBox{
public static void main(String[] args){
JFrame frame = new JFrame("The Check Box Example");
JCheckBox chk = new JCheckBox("Check Box 1");
JCheckBox chk = new JCheckBox("Check Box 2");
JCheckBox chk = new JCheckBox("Check Box 3");
frame.add(chk);
frame.setSize(400, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Showing posts with label java swing. Show all posts
Showing posts with label java swing. Show all posts
Tuesday, June 17, 2008
Thursday, March 20, 2008
Maximize a Frame using Swing
import java.awt.*;
import javax.swing.*;
public class SwingSetBounds{
public static void main(String[] args){
JFrame frame = new JFrame();
Rectangle bounds = new Rectangle(0, 0, 500, 500);
frame.setMaximizedBounds(bounds);
frame.setSize(400, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Friday, February 22, 2008
Remove Title Bar : Java Swing Code
import javax.swing.*;
public class RemoveTitleFrame{
public static void main(String[] args) {
JFrame frame = new JFrame(Frame With No Title Bar);
frame.setUndecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,400);
frame.setVisible(true);
}
}
Labels:
java swing,
swing example,
swing frame
Tuesday, January 15, 2008
Java Swing Example
It is very interesting part of Java programming. It is the favorite topic of all the java programmers. We can customize the components and use it according to our requirements. Lets start with first program :
This program explain you how to create text area using Java swing. Here we are using javax.swing package to create GUI component. The text area will be created on panel in the frame :
import javax.swing.*;
public class TextAreaCode {
public static void main(String[] args){
JFrame frame= new JFrame("TextArea-Frame Program");
JPanel panel=new JPanel();
JTextArea jt= new JTextArea("TextArea Example",4,20);
frame.add(panel);
panel.add(jt);
frame.setSize(250,250);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Click Here for More example on Java Swing
Subscribe to:
Posts (Atom)