package javaapplication1;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
public class NewJApplet extends JFrame
{
public NewJApplet(String title)
{
super(title);
setLayout(new FlowLayout());
//setLayout(new GridLayout(2,2));
JLabel jl1 = new JLabel("Label 1 ");
JLabel jl2 = new JLabel("Label 2 ");
JButton jb1 = new JButton("ok");
JButton jb2 = new JButton("cancel");
JTextField jt1 = new JTextField("text box here");
JTextField jt2 = new JTextField("text box 2");
ButtonGroup bg = new ButtonGroup();
JRadioButton jr1,jr2;
jr1
= new JRadioButton("Male");
jr2
= new JRadioButton("Female");
dd(jr1);
add(jr2);
bg.add(jr1);
bg.add(jr2);
add(jl1);
add(jl2);
add(jb1);
add(jb2);
add(jt1);
add(jt2);
}
public static void main(String args[])
{
NewJApplet obj = new
NewJApplet("Swing1 demo here");
obj.setSize(300,100);
obj.setVisible(true);
}
}
Output :
FlowLayout :
GridLayout :
No comments:
Post a Comment