CardLayout in Java change by action in one of the 'cards'

前端 未结 2 882
渐次进展
渐次进展 2020-12-21 09:36

I am making a simple game using a JFrame. I have made a simple \"Start\" screen which basically consists of a String and a JButton. I

2条回答
  •  萌比男神i
    2020-12-21 10:05

    Your StartScreen class has to have access to the instance of the CardLayout of the JFrame and the instance of the VirusGamePanel class. You can pass these instances in the constructor or a setLayout method and setVirusGamePanel method of your StartScreen class.

    Something like:

    layout.next(virusGamePanel);
    

    should work.

提交回复
热议问题