Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Pull Out JPanel

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Pull Out JPanel

    I am trying to figure out how to have pop out Jpanel in a Jframe.

    Please see the image below as an example of what I mean, the white box is the jframe and the orange box is the panel and tab. Left image is of the window with no focus on the tab/panel and the right one is with mouse focus on tab/panel.

    I would like to see a small tab exposed in the window and then when the mouse hovers over it a panel slides out with controls on. While the mouse is within this panel and tab the panel stays exposed and then when the mouse moves outside of this it retreats back to its initial position. I can easily do the sliding of the frame via threads etc. its more how do I create the tab and panel (single panel with background image of panel and tab using transparencies???) and how do track if the mouse is within it?


    JFrame.png


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 697 Times in 679 Posts

    Default Re: Pull Out JPanel

    When you figure it out, please write a tutorial.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,475
    Thanks
    53
    Thanked 2,405 Times in 2,358 Posts

    Default Re: Pull Out JPanel

    Also posted at: Pull Out JPanel
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Pull Out JPanel

    You would have to write your own component using the GlassPanes of the frame.
    Read this:
    How to Use Root Panes (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)


    The component itself should not be too difficult to implement if you are somewhat used to swing.

  5. #5
    Junior Member
    Join Date
    Sep 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Pull Out JPanel

    Can you give me some sudo code for this please or an idea of how to use this glasspane approach

  6. #6
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 832 Times in 772 Posts
    Blog Entries
    5

    Default Re: Pull Out JPanel

    Quote Originally Posted by teslaa View Post
    Can you give me some sudo code for this please or an idea of how to use this glasspane approach
    Recommended reading: How to Use Root Panes (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

  7. #7
    Junior Member
    Join Date
    Sep 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Pull Out JPanel

    I don't see how glasspane can be used to achieve this capability

  8. #8
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Pull Out JPanel

    The glass pane can be used to draw anything on top of other components within your frame. To my knowledge there is no better approach to doing that.
    If the Panel you want to pull out is simple you can implement it completely as a separate component and use that component as a glass pane.
    If the panel is supposed to be a container it can get a little bit more tricky and you will also need a custom layout manager for your glass pane to position the container contents correctly.

Similar Threads

  1. Replies: 0
    Last Post: April 1st, 2014, 08:12 PM
  2. JPanel within JPanel causing odd stretching behavior.
    By mstabosz in forum AWT / Java Swing
    Replies: 7
    Last Post: September 2nd, 2013, 06:32 AM
  3. Need suggestion to implement PULL model within application
    By java_user_new in forum Java Theory & Questions
    Replies: 0
    Last Post: June 6th, 2012, 04:37 AM
  4. [SOLVED] Pesky <JPanel>.getWidth() and <JPanel>.getHeight() Methods...
    By snowguy13 in forum AWT / Java Swing
    Replies: 1
    Last Post: December 31st, 2011, 03:35 PM
  5. Creating and displaying a JPanel inside another JPanel
    By JayDuck in forum AWT / Java Swing
    Replies: 1
    Last Post: April 7th, 2009, 08:02 AM