Adding an actionlistener to a JButton with no text
I'm having trouble figuring this out. I would normally just do something like
JButton blah = new JButton("blah");
String str = e.getActionCommand();
but now I'm using an icon for the JButton instead of text.
ImageIcon createIcon = new ImageIcon("images/new.png");
JButton create = new JButton(createIcon);
what would I do in the eventhandler class?
Re: Adding an actionlistener to a JButton with no text
Presuming 'e' is an ActionEvent from an ActionListener registered with the JButton - use the setActionCommand method of JButton, or compare the source of the event to the Component, or separate out into a single ActionListener to Listen to only that JButton, ...many ways
Edit: and please read the forum rules. Double posting is not allowed. Your other post has been deleted and I have moved this to a more appropriate location