Results 1 to 2 of 2
  1. #1
    supertreta is offline Member
    Join Date
    Aug 2010
    Rep Power

    Default Java Swing - Defining a empty panel for a SplitPane

    Hi again,

    I have the next components created on a JFrame:

    Java Swing - Defining a empty panel for a SplitPane-fig2.jpg

    The code used to instantiate this frame is:

    Java Code:
    public MyFrame(){           
        _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);
        _mainPanel.setLayout(new BorderLayout());
        _mainPanel.add(_buttonsPanel, BorderLayout.SOUTH);
        _mainPanel.add(_splitPane, BorderLayout.CENTER);
    As I defined, the emptyPanel is not opaque and I can see the mainPanel's components. However, I can not interact with them.

    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,

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Rep Power

    Default 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

  1. Replies: 1
    Last Post: 05-12-2011, 08:09 AM
  2. Defining numerical set in java
    By veronique in forum New To Java
    Replies: 8
    Last Post: 05-04-2011, 08:08 AM
  3. menubar in splitpane
    By masa in forum AWT / Swing
    Replies: 1
    Last Post: 12-16-2008, 09:01 AM
  4. Swing SplitPane Example
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 07:46 PM
  5. how to place a divider of the splitpane?
    By christina in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 07:41 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts