I'm working on a memory game program. I have 30 JButtons on a JPanel. When the user is clicking and finds a match (meaning two buttons with the same image) I want to change the image on the JButton to a different image. However this does not happen while the program is running.
How can I do this?
I was doing this:
where cardBack is an ImageIcon that I already have. That is the correct way to change an icon. Your error is probably somewhere else in the code.
以上就是How to change the image of a JButton?的详细内容，更多请关注web前端其它相关文章！