I have a JFrame
and a JPanel
, and I desire that the JPanel
is shown in the JFrame
.
I have written the following code:
public MainScreen() {
initComponents();
setVisible(false);
setExtendedState(JFrame.MAXIMIZED_BOTH);
PnlButons pnlButons = new PnlButons();
pnlButons.setSize(pnlButons.getHeight(),JFrame.MAXIMIZED_VERT);
add(pnlButons,BorderLayout.WEST);
setVisible(true);
pack();
}
I tried many tutorials, but none of them helped and the JPanel
isn't displayed.