Change Images on jframe when a button is clicked in Java

前端 未结 2 2025
心在旅途
心在旅途 2021-01-28 01:57

I have been trying to figure this out why not the next picture showing on the same panel after click the button. I want to separate those classes not into one class and used rep

2条回答
  •  半阙折子戏
    2021-01-28 02:36

    You can also use ImageIcon like this

    image = new ImageIcon(imageList[1]);
    

    and when each time button is clicked you can change image like this

    label.setIcon(image);
    

提交回复
热议问题