code_junkie

How do you add an ActionListener onto a JButton in Java

Nov 12th, 2011
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. private JButton jBtnDrawCircle = new JButton("Circle");
  2. private JButton jBtnDrawSquare = new JButton("Square");
  3. private JButton jBtnDrawTriangle = new JButton("Triangle");
  4. private JButton jBtnSelection = new JButton("Selection");
  5.  
  6. jBtnSelection.addActionListener(new ActionListener() {
  7. public void actionPerformed(ActionEvent e) {
  8. selectionButtonPressed();
  9. }
  10. } );
  11.  
  12. jBtnDrawCircle.addActionListener( /*class that implements ActionListener*/ );
Add Comment
Please, Sign In to add comment