visualizing JPanel change within a loop

后端 未结 3 971
感动是毒
感动是毒 2021-01-27 16:55

I am new to Java swing programming. I want to make a frame which will appear red and blue in turn one after another. So, I took 2 child JPanel, 1 for red and other for blue, and

3条回答
  •  太阳男子
    2021-01-27 17:42

    I would suggest to take in one step at a time.
    First make it run without changing panels / colors.
    Now it doesn't because this

    public final void Test2() {
    

    is a method (which is never used) and not a constructor. Change to a constructor declaration like :

    public  Test2() {
    

    to make the program do something. Then you can go to the next step.

    Also use Java naming conventions (like blue instead of Blue).

提交回复
热议问题