//Java swing Example Program 1
import java.awt.*;
import javax.swing.*;
public class Scompon{
private JFrame f;
private JButton b;
private JLabel l1,l2;
private JTextField tf1,tf2;
private JRadioButton rb;
private JCheckBox cb;
private JComboBox comb;
private JTable jt;
public Scompon(){
f = new JFrame("JComponents Demo");
b = new JButton("Button1");
l1 = new JLabel("Enter Your name");
l2 = new JLabel("enter Your no");
tf1 = new JTextField(20);
tf2 = new JTextField(20);
rb = new JRadioButton("C++");
cb = new JCheckBox("Java");
comb = new JComboBox();
comb.addItem("India");
comb.addItem("pak");
comb.addItem("USA");
String d[][]={{"sun","sunmicrosys","bangalore"},{"mic","microsoft","chennai"}};
String h[]={"key","value","place"};
jt = new JTable(d,h);
}
public void dispFrame(){
f.setLayout(new FlowLayout());
f.add(l1);
f.add(tf1);
f.add(l2);
f.add(tf2);
f.add(b);
f.add(rb);
f.add(cb);
f.add(comb);
f.add(jt);
f.pack();
f.setVisible(true);
}
public static void main(String arg[]){
Scompon e = new Scompon();
e.dispFrame();
}
}
import java.awt.*;
import javax.swing.*;
public class Scompon{
private JFrame f;
private JButton b;
private JLabel l1,l2;
private JTextField tf1,tf2;
private JRadioButton rb;
private JCheckBox cb;
private JComboBox comb;
private JTable jt;
public Scompon(){
f = new JFrame("JComponents Demo");
b = new JButton("Button1");
l1 = new JLabel("Enter Your name");
l2 = new JLabel("enter Your no");
tf1 = new JTextField(20);
tf2 = new JTextField(20);
rb = new JRadioButton("C++");
cb = new JCheckBox("Java");
comb = new JComboBox();
comb.addItem("India");
comb.addItem("pak");
comb.addItem("USA");
String d[][]={{"sun","sunmicrosys","bangalore"},{"mic","microsoft","chennai"}};
String h[]={"key","value","place"};
jt = new JTable(d,h);
}
public void dispFrame(){
f.setLayout(new FlowLayout());
f.add(l1);
f.add(tf1);
f.add(l2);
f.add(tf2);
f.add(b);
f.add(rb);
f.add(cb);
f.add(comb);
f.add(jt);
f.pack();
f.setVisible(true);
}
public static void main(String arg[]){
Scompon e = new Scompon();
e.dispFrame();
}
}
No comments:
Post a Comment