Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By KevinWorkman

Thread: JPanel question.

  1. #1
    santa's Avatar
    santa is offline Senior Member
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    208
    Rep Power
    5

    Default JPanel question.

    I decided to work with JPanels in staid of JInternalFrame. The JPanel will be displayed inside another JPanel (MainPanel) at the mouse pointer and will contain information about the object that was clicked on by the mouse.
    So my question is; Is it better to create a new panel every time the panel is to be displayed or "show and hide" the panel with new data in staid?
    Also will it work if i just add the new panel to the "MainPanel" and then use the setlocation(x,y); to position it by the mouse?

    Thanks...

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default Re: JPanel question.

    That depends on what your definition of "better" is as well as the specifics of your requirements (where your data is coming from, what's being displayed, what changes, etc) . I'd recommend you do a test of each and decide for yourself.

    As for adding the new panel, you might want to make sure you remove old panels, and you have to keep in mind things like overlapping components, revalidating, etc. You might want to look into adding it to a GlassPane instead.
    santa likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    santa's Avatar
    santa is offline Senior Member
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    208
    Rep Power
    5

    Default Re: JPanel question.

    Sounds like its better to use the glassPane ... If i want to add a JPanel on the glasspane should I use the default glassPane? I have no experience with the glasspane. Thanks

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default Re: JPanel question.

    What happened when you tried?

    Recommended reading: A well-behaved GlassPane | Java.net
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    santa's Avatar
    santa is offline Senior Member
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    208
    Rep Power
    5

    Default Re: JPanel question.

    Yeah ... I didn't try yet :P still reading about it in How to Use Root Panes (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components). Im still amazed by that my java book has zero on the glassPane ..

Similar Threads

  1. Replies: 1
    Last Post: 12-13-2011, 02:38 AM
  2. Change JPanel text of Parent JPanel from JDialog
    By bikashlama in forum AWT / Swing
    Replies: 7
    Last Post: 12-09-2011, 03:47 AM
  3. Question about repainting a JPanel
    By Nosrettap in forum Advanced Java
    Replies: 5
    Last Post: 01-02-2011, 08:29 PM
  4. Need help with array list jpanel question!!! Plz help!!!
    By helpmeplease in forum New To Java
    Replies: 17
    Last Post: 12-11-2009, 12:37 PM
  5. Replies: 3
    Last Post: 04-20-2009, 11:31 PM

Posting Permissions

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