I\'m doing a board game project and I\'m representing cells by Jbuttons. I made mouseLitener to all the buttons. My question is how to change the icon of the Jbutton when it
yourButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { yourButton.setIcon(new ImageIcon("yourImage")); } });
ActionListener is called when you click on the JButton. This way is used most frequently.