Guest User

Nebelmann

a guest
Nov 13th, 2007
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. import java.awt.* ;
  2. import java.awt.event.* ;
  3.  
  4. public class layout extends Frame implements ActionListener
  5. {
  6.         private Button b; // en rendant b globale, tu y as acc�s dans actionPerformed
  7.  
  8.         public layout() {
  9.            super("BorderLayout");
  10.  
  11.            b = new Button ("Quitter") ;
  12.            TextArea ta = new TextArea () ;
  13.  
  14.            b.addActionListener(this) ;
  15.  
  16.  
  17.            this.setLayout(new FlowLayout());
  18.            this.add ("North", ta);
  19.            this.add("South", b) ;
  20.            this.setSize (300, 300) ;
  21.            this.setBackground (Color.gray) ;
  22.         }
  23.  
  24.         public static void main (String[]args) {
  25.            new layout().show();
  26.         }
  27.  
  28.  
  29.         public void actionPerformed(ActionEvent evt)
  30.         {
  31.            Object obj = evt.getSource() ;
  32.            if (obj.equals(b))
  33.            {
  34.                 // code quand on clique sur le bouton
  35.                 System.exit(0);
  36.            }
  37.  
  38.         }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment