Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.* ;
- import java.awt.event.* ;
- public class layout extends Frame implements ActionListener
- {
- private Button b; // en rendant b globale, tu y as acc�s dans actionPerformed
- public layout() {
- super("BorderLayout");
- b = new Button ("Quitter") ;
- TextArea ta = new TextArea () ;
- b.addActionListener(this) ;
- this.setLayout(new FlowLayout());
- this.add ("North", ta);
- this.add("South", b) ;
- this.setSize (300, 300) ;
- this.setBackground (Color.gray) ;
- }
- public static void main (String[]args) {
- new layout().show();
- }
- public void actionPerformed(ActionEvent evt)
- {
- Object obj = evt.getSource() ;
- if (obj.equals(b))
- {
- // code quand on clique sur le bouton
- System.exit(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment