I am trying to make a gui where I use a splitPane with stuff on the left and the main content on the right. I realized that when the splitPane gets resized the content from the right panel moves accordingly to fit the new size which is not the behavior I am looking for, I want the main content on the right to remain as is when I resize. So I used a layeredPane to add the main content behind a split pane that has stuff on the left and a transparent panel on the right to show the main content behind it.
Here is a snippet of my code
JPanel phantomPanel = new JPanel();
phantomPanel.setOpaque(false);
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, phantomPanel);
JLayeredPane layeredPane = new JLayeredPane();
rightPanel.setBounds(0,0,900,600);
splitPane.setBounds(0,0,900,600);
layeredPane.add(rightPanel,0,0); //Main Content is behind the split pane
layeredPane.add(splitPane, 1,0);
I am seeing the splitPane with the left panel as it should be but the right panel is white, switching the layers on the layeredPane I do see my (non white) main panel.
Changing the background color of the right panel I realized that the white is indeed the transparent panel and the problem is that the panel behind it isn't showing. What am I missing?
The split Pane with the non transparent right panel What should show behind it