Java Swing - Defining a empty panel for a SplitPane
I have the next components created on a JFrame:
The code used to instantiate this frame is:
As I defined, the emptyPanel is not opaque and I can see the mainPanel's components. However, I can not interact with them.
_mainPanel = new MyMainPanel();
_ListPanel = new MySideListPanel();
_ListPanel.setMinimumSize(new Dimension(NOW_PLAYLING_LIST_MIN_WIDTH, 100));
javax.swing.JPanel emptyPanel = new javax.swing.JPanel();
_splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, emptyPanel, _ListPanel);
This doesn't happen with the buttonsPanel, where I can see and interact with the mainPanel's components between the buttons.
I think the problem is because I don't add the emptyPanel directly over the mainPanel. I add the SplitPane, which contains the emptyPanel.
What should I do?
Thanks in advance,
Re: Java Swing - Defining a empty panel for a SplitPane
I would guess that opaqeness is only for painting.
Just because a component is transparent doesn't mean the component isn't there. So when you click in the area I would guess the split pane still receives the mouse event.
I'm not sure why you would design a form like this.
For a possible solution see: How to Use Root Panes (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components). The Glass Pane example shows how to forward events to components hidden under the glass pane.