How to change the image of a JButton?

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: cards[i].setIcon(cardBack); 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前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准