Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package awtHomework2a;
- import java.awt.*;
- import java.awt.event.*;
- public class AWTHomework2a extends Frame {
- private Panel buttonsWest = new Panel( new GridLayout(3,1));
- private Panel buttonsCenter = new Panel( new GridLayout(2,2));
- private Panel buttonsSouth = new Panel();
- public AWTHomework2a() {
- for(int i=0; i<3; i++){
- buttonsWest.add(new Button("Button1"+(i+1)));
- buttonsCenter.add(new Button("Button2"+(i+1)));
- buttonsSouth.add(new Button("Button3"+(i+1)));
- }
- buttonsCenter.add(new Button("Button24"));
- this.add(buttonsWest, BorderLayout.WEST);
- this.add(buttonsCenter, BorderLayout.CENTER);
- this.add(buttonsSouth, BorderLayout.SOUTH);
- this.setTitle("LayoutManagersDemo");
- this.setSize(250,150);
- this.setVisible(true);
- this.addWindowListener( new WindowClosing());
- }
- public static void main(String[] args){
- new AWTHomework2a();
- }
- class WindowClosing extends WindowAdapter {
- public void windowClosing(WindowEvent e){
- System.exit(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment