I started working with a Java desktop application using netbeans. I have 7 different screens, and I use JPanel to represent them. One JPanel represents each of them and one to contain all of them (called mainPanel), which is inside the JFrame. mainPanel uses Cardlayout to switch between screens (JPanels). I built this whole interface using netbeans ui widgets, i.e. Drag and drop.
Markup
JFrame mainPanel (Jpanel) CardLayout Child1 (JPanel) Child2 (JPanel) . . . . Childn (Jpanel)
I know that you can switch screens using JPanel.next() and Jpanel.previous . but they can only be used when switching between successive screens, that is, if you need to switch to the nearest neighbor. There is also a way for JPanel.show() to go to a specific screen, but the problem is that it accepts the name parameter, which is the String that you are binding by adding it to mainPanel using the JPanel.add() function. I added everything using drag and drop, so I donβt know what String binds, if that is the case. Although it looks very primitive, and I already did it without Cardlayout , but this time Cardlayout is a requirement.
Help would be greatly appreciated
moCap source share