setLayout(new FlowLayout()); addWindowListener(this); b1.addActionListener(this); b2.addActionListener(this); add(b1); add(b2);
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");
Frame f = new BadIdea1(); f.setSize(300,200); f.setVisible(true);
System.out.println("Window Closing"); System.exit(0);