I have a JFrame
with 10 JPanel
components that were put using Swing. I have one panel created from code. I added JLabel
and stuff on it.
The problem is when I try to center all the panels using the GridBagLayout
on frame. The panels are centered, but the one that I created manually doesn't appear anymore.
How to make the manually created one appear?
Code in main:
Interface f = new Interface();
f.setExtendedState(f.getExtendedState() | JFrame.MAXIMIZED_BOTH);
f.setLayout(new GridBagLayout());
f.setVisible(true);
Code to add the manually created panel to JFrame:
this.getContentPane().add(hotelPanel);
hotelPanel.setSize(800, 1000);
hotelPanel.setLocation(300, 1);
hotelPanel.setVisible(false);