Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 15th, 2012  |  syntax: None  |  size: 0.95 KB  |  views: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.awt.event.ActionListener;
  2. import javax.swing.JButton;
  3. import javax.swing.JFrame;
  4. import javax.swing.JPanel;
  5.  
  6. public class ButtonTester_P12_3
  7. {  
  8.     public static void main(String[] args)
  9.     {  
  10.         JFrame frame = new JFrame();
  11.         JButton button = new JButton("Button A");
  12.        
  13.         ActionListener listener = new ClickListener_P12_3();
  14.         button.addActionListener(listener);
  15.  
  16.         JButton button2 = new JButton("Button B");
  17.  
  18.         ActionListener listener2 = new ClickListener_P12_3();
  19.         button2.addActionListener(listener2);
  20.  
  21.         JPanel panel = new JPanel();
  22.         panel.add(button);
  23.         panel.add(button2);
  24.         frame.add(panel);
  25.  
  26.         frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
  27.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  28.         frame.setVisible(true);
  29.     }
  30.  
  31.     private static final int FRAME_WIDTH = 100;
  32.     private static final int FRAME_HEIGHT = 110;
  33. }
clone this paste RAW Paste Data