I am trying to make 3 panels re-size over each other I wrote the code for it. it should work. However, it did not. I am making 3 JPanel
components, adding them to two split panes the first split pane holds The middle panel, and the Right panel. The second split pane holds the same middle panel, and the left panel, so the middle panel is in both split panes.
If you can help me with tackling this issue, I would be very grateful.
public class FinalProjectTestCase1 {
public static void main(String[] args)
{
Frame frame = new Frame();
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
}
}
class Frame extends JFrame
{
JPanel LeftPanel;
JPanel MiddlePanel;
JPanel RightPanel;
Frame()
{
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(700,700));
MiddlePanel= new JPanel();
MiddlePanel.setLayout(new GridLayout());
RightPanel= new JPanel();
RightPanel.setLayout(new GridLayout());
RightPanel.setPreferredSize(new Dimension(250,700));
LeftPanel= new JPanel();
LeftPanel.setLayout(new GridLayout());
LeftPanel.setPreferredSize(new Dimension(250,700));
JButton MiddlePanelb= new JButton("MiddlePanel");
MiddlePanel.add(MiddlePanelb);
JButton leftPanelb= new JButton("leftPanelb");
LeftPanel.add(leftPanelb);
JButton RightPanelb= new JButton("RightPanelb");
RightPanel.add(RightPanelb);
JSplitPane RightSplitPane= new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,(MiddlePanel),(RightPanel));
JSplitPane LeftSplitPane= new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,(LeftPanel),(MiddlePanel));
this.add(MiddlePanel);
this.add(RightSplitPane,BorderLayout.EAST);
this.add(LeftSplitPane,BorderLayout.WEST);
}
}