0

I am trying to collapse the JXCollapsiblePane by setting the JXCollapsiblePane.setCollapsed(true).

But it doesn't seem to work.. What can be a possible reason?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Nigel Thomas
  • 1,881
  • 8
  • 30
  • 50
  • for better help sooner post an [SSCCE](http://sscce.org/), short, runnable, compilable, just about `J(X)Frame` and `JXCollapsiblePane` – mKorbel Dec 11 '12 at 08:17

1 Answers1

2

In what kind of a layout is the collapsible pane contained? Sometimes the layout managers prevent a pane to collapse. I had the best experience if I put the JXCollapsiblePane into the NORTH part of a JPanel with BorderLayout. If that doesn't help, post a small code example so others can try it out as well.

cello
  • 5,356
  • 3
  • 23
  • 28
  • 2
    +1 for the LayoutManager hunch :-) @nigelthomas As documented (cough .. did we really ..), the collapsible needs a LayoutManager which always sizes according to a component's prefSize – kleopatra Dec 11 '12 at 08:23
  • There is a JXTitledPane inside which the JXCollapsiblePane is placed. There is a JPanel inside the JXCollapsiblePane. Inside the JPanel there is another JPanel. – Nigel Thomas Dec 11 '12 at 09:19
  • The JXTitledPane will likely not make a difference. The BorderLayout around will optimize the inside panels' dimension. In this case, it will make the JXTitlePane larger if it seems to be "nicer". The JXTitlePane will thus also increase its containing JXCollapsiblePane, preventing it from Collapsing (basically the same as what kleopatra said: the GroupLayout ignores the prefSize of a component, thus not meeting the requirements). Try having your JPanel/GroupLayout containing a JPanel with BorderLayout, and place the JXTitlePane inside the NORTH part of that one. – cello Dec 11 '12 at 20:57