I am trying to design an interface with 4 different panels in 1 single frame. I have included 2 of the panel descriptions in the code I included below.
Below is part of my code:
public class finalFrame extends JFrame {
PanelA a = new PanelA()
PanelB b = new PanelB()
// ...
public finalFrame() {
super();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//...
//...
//...
add(a);
add(b);
}
}
class PanelA extends JPanel {
JButton bt = new JButton();
add(bt);
//...
}
class PanelB extends JPanel {
// ...
//... }
class Program {
public static void main(String [] args) {
finalFrame fr = new finalFrame();
}
}
This code doesn't seem to work (it only displays the last panel at an odd size (Not what I wanted)). Yet, when I set up the different panels WITHIN the frame class (and not individual panel classes), it works perfectly. Why can't I use different panel classes and then just add them all to the final Frame class afterwards?
Furthermore (sorry for all the questions), if I include the panel set up within the frame class and include a frame layout, then it works (as I just mentioned). However, if I include the panel set up within the frame class but I DON'T include a frame layout, then it only displays the last panel using the frame layout. Why isn't it portraying any of the other panels??
Thank you!!