package lord1;
import javax.swing.*;
import java.awt.*;
public class guiframe extends JFrame
{
private static final Color yellowgreen = null;
private Container con=getContentPane();
final int width_of_Frame=400;
final int height_of_Frame=150;
JLabel first=new JLabel (" Enter first number :");
JLabel second=new JLabel("Enter second number :");
JTextField firstfield=new JTextField(10);
JTextField secondfield=new JTextField(10);
JButton ok = new JButton (" 1OK" );
JButton Cancel = new JButton("Cancel");
public guiframe()
{
super("My JFrame");
setSize(width_of_Frame,height_of_Frame);
JPanel firstfieldpane =new JPanel();
JPanel secondfieldpane =new JPanel();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
con.setBackground(Color.green);
con.setLayout(new FlowLayout());
con.add(first);
con.add(firstfieldpane);
con.add(ok);
con.add(second);
con.add(secondfieldpane);
con.add(Cancel);
ok.setBackground(Color.green);
Cancel.setBackground(Color.green);
firstfieldpane.add(firstfield);
firstfieldpane.setBackground(Color.orange);
secondfieldpane.add(secondfield);
secondfieldpane.setBackground(Color.orange);
}
public static void main(String[]args)
{
guiframe myframe=new guiframe();
myframe.setVisible(true);
}
}
No comments:
Post a Comment