FileDocCategorySizeDatePackage
BadIdea2.javaAPI DocExample3573Mon Apr 06 18:10:22 BST 1998None

BadIdea2

public class BadIdea2 extends Frame implements ActionListener

Fields Summary
Button
b1
Button
b2
Constructors Summary
public BadIdea2()

    
    setLayout(new FlowLayout());
    addWindowListener(new WL());
    b1.addActionListener(this);
    b2.addActionListener(this);
    add(b1);
    add(b2);
  
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)

    Object source = e.getSource();
    if(source == b1)
      System.out.println("Button 1 pressed");
    else if(source == b2)
      System.out.println("Button 2 pressed");
    else
      System.out.println("Something else");
  
public static voidmain(java.lang.String[] args)

    Frame f = new BadIdea2();
    f.setSize(300,200);
    f.setVisible(true);