Write code:
import java.awt.*;
public class AWT001 extends Frame{
private Button bt1 = new Button("Confirm");
private Button bt2 = new Button("Cancel1");
private Button bt3 = new Button("Cancel2");
private BorderLayout bl = new BorderLayout();
private Panel p1 = new Panel();
private Panel p2 = new Panel();
public AWT001(String title){
/*Initialization*/
super(title);
setSize(400, 300);
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension size = getSize();
int xpos = screen.width / 2 - size.width / 2;
int ypos = screen.height / 2 - size.height / 2;
setLocation(xpos,ypos);
setVisible(true);
/*Add
Component*/
init();
/*Event
handling*/
start();
}
public void init(){
this.setLayout(bl);
p1.setLayout(new GridLayout(1,2));
p1.add(bt1);
p2.setLayout(new GridLayout(2,1));
p2.add(bt2);
p2.add(bt3);
p1.add(p2);
this.add(BorderLayout.SOUTH,p1);
}
public void start(){
}
public static void main(String[] args) {
AWT001 obj = new AWT001("Title!!!!");
}
}
No comments:
Post a Comment