In Java, when using the BorderLayout, is it possible to have two panels in the CENTER, but both be visible on the form.
Here is my code:
guiFrame.add(guiFieldsPanel, BorderLayout.CENTER);
guiFrame.add(guiButtonsPanel, BorderLayout.CENTER);
guiFrame.setVisible(true);
In the above code, both panels are set to the center, yet I can only see the guiButtonsPanel as it is 'on top' of the guiFieldsPanel.
Can i group both panels together, and then set them to be displayed in the CENTER?
解决方案
See the Nested Layout Example for ideas about how to combine layouts to create the required layout. E.G.
Perhaps use a single row GridLayout for the center.
guiFrame.add(guiFieldsPanel, BorderLayout.CENTER);
guiFrame.add(guiButtonsPanel, BorderLayout.CENTER);
But that suggests a 2 column GroupLayout as seen in this answer. E.G.