Results 1 to 7 of 7
  1. #1
    calexander is offline Member
    Join Date
    Nov 2008
    Posts
    5
    Rep Power
    0

    Default Managing jPanels in jSplitPane

    Ladies and Gentlemen,

    I am a .NET developer making the switch to Java for future development. Currently, I am authoring a swing application (Netbeans 6.1) that leverages multiple jPanels in an attempt to mimic a MDI UI. The parental UI hierarchy is:

    Form > Main Panel > jSplitPane > jPanel

    I have design-time default jPanels in the jSplitPane. So here are my questions:

    1. When I dynamically instantiate and display jPanels, everything is fine. But when I hide and dispose those dynamic jPanels, my default jPanel is invisible. How do I redisplay my default jPanel?
    2. How can I bubble-up jPanel events to my top-most Form? Is there a built-in event framework I can leverage or do I have to author a custom event model.

    Thanks for your assistance.

    Chris

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Are you sure that you don't want to use a JDesktopPane and have it hold several JInternalFrames? This would come closer to looking and acting like an MDI I believe. You can read up on it here:
    How to Use Internal Frames (The Java™ Tutorials > Creating a GUI with JFC/Swing > Using Swing Components)

  3. #3
    calexander is offline Member
    Join Date
    Nov 2008
    Posts
    5
    Rep Power
    0

    Default

    Thanks for the feedback Fubarable. I have examined use of jInternalFrames but I want to maintain a jTreeView on the left side of the main window. I have chosen a SingleFrameApplication type with a FrameView, which allows me to do this. Therefore, I still need to use the jSplitPane, loading jPanels in and out within the right-most pane. Any other suggestions you have are appreciated.

    :)

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    If you are only showing one JPanel at time in the right pane of the JSplitPane, you may wish to look into using a CardLayout. This will allow you to easily, quickly and conveniently swap JPanels (or other JComponents) in and out.

  5. #5
    calexander is offline Member
    Join Date
    Nov 2008
    Posts
    5
    Rep Power
    0

    Default

    I explored the cardlayout and it looks like a very good fit. Thanks! I will move forward with it. As for bubbling events up the parent hierarchy... it looks like I will have to code custom events and eventlisteners for the Form to be notified of jPanel events. Is this the correct strategy here?

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    My (non-professional mind you) thoughts on that is to try to separate the logic from the GUI as much as possible, or when the logic is tied to the GUI, to use design patterns to keep coupling low. I often use the Observable or Command patterns when trying to tie separate home-made GUI components together.

  7. #7
    calexander is offline Member
    Join Date
    Nov 2008
    Posts
    5
    Rep Power
    0

    Default

    Exactly! I have already begun to put together a package using the observable design pattern to manage GUI-based events. I just wanted to ensure that I wasn't reproducing something that has already been built into the Java desktop framework. Thank you very much for your feedback - it is appreciated.

    Chris

Similar Threads

  1. JSplitPane nightmare
    By SwinGirl in forum SWT / JFace
    Replies: 1
    Last Post: 05-01-2008, 08:24 PM
  2. Managing Gigabytes for Java 2.1.1
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 03-01-2008, 10:23 PM
  3. Managing Gigabytes for Java 2.0
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 07-07-2007, 02:27 PM
  4. I need create a JSplitPane
    By Daniel in forum AWT / Swing
    Replies: 1
    Last Post: 07-05-2007, 06:12 AM

Posting Permissions

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