VasilM

AWTHomework2a

Apr 10th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. package awtHomework2a;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4.  
  5. public class AWTHomework2a extends Frame {
  6.  
  7.     private Panel buttonsWest = new Panel( new GridLayout(3,1));
  8.     private Panel buttonsCenter = new Panel( new GridLayout(2,2));
  9.     private Panel buttonsSouth = new Panel();
  10.    
  11.     public AWTHomework2a() {
  12.         for(int i=0; i<3; i++){
  13.             buttonsWest.add(new Button("Button1"+(i+1)));
  14.             buttonsCenter.add(new Button("Button2"+(i+1)));
  15.             buttonsSouth.add(new Button("Button3"+(i+1)));
  16.         }
  17.         buttonsCenter.add(new Button("Button24"));
  18.         this.add(buttonsWest, BorderLayout.WEST);
  19.         this.add(buttonsCenter, BorderLayout.CENTER);
  20.         this.add(buttonsSouth, BorderLayout.SOUTH);
  21.         this.setTitle("LayoutManagersDemo");
  22.         this.setSize(250,150);
  23.         this.setVisible(true);
  24.         this.addWindowListener( new WindowClosing());
  25.     }  
  26.    
  27.     public static void main(String[] args){
  28.         new AWTHomework2a();
  29.     }
  30.    
  31.     class WindowClosing extends WindowAdapter {
  32.         public void windowClosing(WindowEvent e){
  33.             System.exit(0);
  34.         }  
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment