Results 1 to 2 of 2
- 01-02-2012, 01:37 PM #1
Member
- Join Date
- Aug 2010
- Posts
- 5
- Rep Power
- 0
Java Swing - Defining a empty panel for a SplitPane
Hi again,
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.Java Code:public MyFrame(){ _mainPanel = new MyMainPanel(); _mainPanel.setTransferHandler(_fileDropHandler); initButtonsPanel(); _ListPanel = new MySideListPanel(); _ListPanel.setMinimumSize(new Dimension(NOW_PLAYLING_LIST_MIN_WIDTH, 100)); javax.swing.JPanel emptyPanel = new javax.swing.JPanel(); emptyPanel.setOpaque(false); _splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, emptyPanel, _ListPanel); _splitPane.setOpaque(false); _splitPane.setOneTouchExpandable(true); _splitPane.setDividerSize(0); _splitPane.setResizeWeight(1.0); _splitPane.setOpaque(false); _mainPanel.setLayout(new BorderLayout()); _mainPanel.add(_buttonsPanel, BorderLayout.SOUTH); _mainPanel.add(_splitPane, BorderLayout.CENTER); getContentPane().add(_mainPanel); }
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,
st
- 01-02-2012, 05:45 PM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
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.
Similar Threads
-
how to add multiple panel in swing as regarding thier menubar item
By vijayjob09 in forum AWT / SwingReplies: 1Last Post: 05-12-2011, 08:09 AM -
Defining numerical set in java
By veronique in forum New To JavaReplies: 8Last Post: 05-04-2011, 08:08 AM -
menubar in splitpane
By masa in forum AWT / SwingReplies: 1Last Post: 12-16-2008, 09:01 AM -
Swing SplitPane Example
By Java Tip in forum javax.swingReplies: 0Last Post: 06-27-2008, 07:46 PM -
how to place a divider of the splitpane?
By christina in forum New To JavaReplies: 1Last Post: 08-06-2007, 07:41 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks