Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JPanel to collapse

 
Knut Nilson
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have a JPanel with many option to personlize the settings. Since it is too much to start with for the user, I would like to collapse the view and than open it with plus/arrow so the full menue is available. Please let me know if/how I need to transfer may be the JPanel into something else.
Thanks for you help.
 
Darryl Burke
Bartender
Posts: 5155
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knut Nilson wrote:Hello,
I have a JPanel with many option to personlize the settings. Since it is too much to start with for the user, I would like to ...

Have you considered using a JTabbedPane? a tabbed pane is a fairly standard programming idiom for multiple settings.
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like an expander. At least, that's what GTK+ calls it. That's not hard to implement; I've done it myself a while ago already.

The setup is pretty basic. You have a main panel with a BorderLayout. At the top you have your controller panel, with the expand / collapse button and its label. In the center you have the main component, mostly a JPanel. Expanding means showing the main component (setVisible(true)), collapsing means hiding it (setVisible(false)).
 
Knut Nilson
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on it, but what I struggle with is to put the CheckBox in the TiledBorder. This is what I have, do you have an additional hint:



To: Darryl Burke
Tabbed Pane is not applicable for this scenario, since I need to be able to show options in one view. But thanks for the hint, if I don't find anything else I now have a plan B
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't use borders that require interaction. Or at least it will be quite tricky. The reason is that a border is "eye candy" - it only determines how it's painted, nothing more. Like I said in my previous post (in other words), using a BorderLayout with a component at BorderLayout.NORTH would be a lot easier.
 
Knut Nilson
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your patients, I will than do this. I know how that is working.
 
Darryl Burke
Bartender
Posts: 5155
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knut Nilson wrote:what I struggle with is to put the CheckBox in the TiledBorder.


May be just what the doctor ordered: Rob Camick's Component Border.

Knut Nilson wrote:To: Darryl Burke
Tabbed Pane is not applicable for this scenario, since I need to be able to show options in one view. But thanks for the hint, if I don't find anything else I now have a plan B

You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!