• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Expand/Collapse Panels

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all

Is it possible to make Expand/Collapsable panels in Java without writing huge amounts of code?

I want something like this Expand/Collapse

How would I go about it?

Thanks
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
bbritta's post here might(?) do what you're after

http://forum.java.sun.com/thread.jspa?forumID=257&threadID=553713
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now that really is a neat bit of code
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lovely bit of code. I modified it a bit, here is a version I found more useful for my application. It is 1) entirely self contained - you pass it a created JPanel and a title String and it sets up everything and 2)not debugged at all (just so you are aware).

Hope it helps,

Hamy

 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the update to an old problem. And welcome to the Ranch
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This works great; however, is there a trick to making the container panel or the mainframe size expand/collapse along with the expand/collapse panel? I've tried different ways, but still haven't gotten it to be perfect. Any suggestions would be greatly appreciated.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my version. Expandable by clicking on the border.



Recommended usage:
  • compile the class
  • create JFrame with netbeans
  • drag the class to the frame
  • recommended: add a panel inside the CollapsiblePanel that would be the holder for your all other controls (though the class should work even if you put several components inside it without additional holder-panel)
  •  
    Greenhorn
    Posts: 1
    jQuery Firefox Browser Tomcat Server
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I know this is a pretty old thread... but let's see if one of you might have some wisdom for me.

    I have historically done web dev, but am currently branching out and working on a swing app. Due to some real estate restrictions, we want to use a collapsible panel... thing is we were hoping for it to move horizontally instead of vertically.

    Is there a way to set a TitledBorder to display the title on a side rather than the top of a panel? Or is there another way I should be looking at doing this?

    Thanks in advance!
     
    Campbell Ritchie
    Marshal
    Posts: 79151
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    It would appear that you can specify title locations, though I have never tried it.

    And welcome to the Ranch
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic