I'm making a game and I want to change an image already being shown. I think the problem is the wording in the actionPerformed
class.
Here's my code:
TwoButtons()
{
setLayout (new FlowLayout());
image = new ImageIcon ("as.jpg");
b = new JButton (image);
b.setActionCommand("a");
b.addActionListener(this);
add(b);
}
public void actionPerformed (ActionEvent evt)
{
if (evt.getActionCommand().equals("a"))
{
image = (new ImageIcon("qd.jpg"));
}
repaint();
}