How can I replace one of two JPanels with another JPanel in Java?

前端 未结 3 459
小蘑菇
小蘑菇 2021-01-24 08:48

I designed an interface for the welcome screen with one JFrame included two JPanels (JPanel1 on right and JPanel2 on left). The buttons on the left is to switch the Panels in JP

3条回答
  •  抹茶落季
    2021-01-24 09:35

    The best answer I found is that I will create one JFrame only and gonna make one big JPanel include two JPanels (JPanelLeft include the buttons and JPanelRight include what the button do) then I will copy the main JPanel for each JButton. When I press on any button I will do (JFrame.getContentPane.removeAll) to remove the old JPanel then (JFrame.getContentPane.Add(NewJPanel).

    This works for me and keep my design as I Want. Thanks for every body.

提交回复
热议问题