0
    JButton bkButton = new JButton(new ImageIcon("src/Images/smallBArrow.bmp"));
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(bkButton);

Using an action listener I need to be able to click and have an action (to go back, forward, or refresh)

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
user1849819
  • 2,889
  • 2
  • 13
  • 3

1 Answers1

5

This is usually done with an anonymous inner class...

bkButton.addActionListener(new ActionListener() { 
    public void actionPerformed(ActionEvent e) { 
        backButtonPressed();
    } 
});

See this answer

Community
  • 1
  • 1
RudolphEst
  • 1,240
  • 13
  • 21
  • especially useful if this is a to-be-used-once action. If you will share a single action across several components, you should declare it as an ActionListener reference, then assign. – Dan Feb 26 '13 at 23:08