swingx
  1. swingx
  2. SWINGX-1461

Incorrect behavior of JXCollapsiblePane when used with MigLayout 'grow' constraint

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.6.2
    • Fix Version/s: 1.6.6
    • Labels:
      None

      Activity

      Hide
      sbozian added a comment -

      I hit the Create button, before entering the issue Description, and now I cannot Edit it. So I'll include the Description here.

      Description: Assume you are using a collapsible panel of type JXCollapsiblePane inside any container (say JXPanel or JXFrame) whose layout manager is of type MigLayout. The problem appears whenever you use the 'grow' MigLayout constraint on the collapsible panel. Ideally, when 'grow' is specified for a component, this component would claim all available space in the cell in which it is added. Now, while this works perfectly well with other components, it doesn't work properly when used with a collapsible panel. What happens is that the panel does no longer collapse/expand properly, and a strange behavior may be observed depending on the current window size, etc.

      Show
      sbozian added a comment - I hit the Create button, before entering the issue Description, and now I cannot Edit it. So I'll include the Description here. Description: Assume you are using a collapsible panel of type JXCollapsiblePane inside any container (say JXPanel or JXFrame) whose layout manager is of type MigLayout. The problem appears whenever you use the 'grow' MigLayout constraint on the collapsible panel. Ideally, when 'grow' is specified for a component, this component would claim all available space in the cell in which it is added. Now, while this works perfectly well with other components, it doesn't work properly when used with a collapsible panel. What happens is that the panel does no longer collapse/expand properly, and a strange behavior may be observed depending on the current window size, etc.
      Hide
      kleopatra added a comment -

      looks like a similar issue:

      http://stackoverflow.com/questions/8434177/jxcollapsiblepane-from-swingx-not-working-correctly

      after digging into that problem, I think that this here is not a bug (except that we might emphasize the limitation that a collapsible must be layed out at its prefSize always even more prominently in the api doc) but an enhancement request.

      To make it play nicely with max-respecting managers, the getMaximumSize() should be overridden to also return the pref.

      Comments?

      Cheers
      Jeanette

      Show
      kleopatra added a comment - looks like a similar issue: http://stackoverflow.com/questions/8434177/jxcollapsiblepane-from-swingx-not-working-correctly after digging into that problem, I think that this here is not a bug (except that we might emphasize the limitation that a collapsible must be layed out at its prefSize always even more prominently in the api doc) but an enhancement request. To make it play nicely with max-respecting managers, the getMaximumSize() should be overridden to also return the pref. Comments? Cheers Jeanette
      Hide
      Karl Schaefer added a comment -

      I agree that we should override getMaximumSize to do what we want as well. More glaring docs won't hurt either. Let's take that path.

      Show
      Karl Schaefer added a comment - I agree that we should override getMaximumSize to do what we want as well. More glaring docs won't hurt either. Let's take that path.
      Hide
      sbozian added a comment -

      Hi Jeanette,

      I read your post at:

      http://stackoverflow.com/questions/8434177/jxcollapsiblepane-from-swingx-not-working-correctly

      and tried your sample with the getMaximumSize() override, and got your point.

      However, while it worked with BoxLayout, the getMaximumSize override didn't solve my problem with MigLayout's 'grow' constraint.

      I modified your example to use MigLayout, as follows.

      public static void main(String[] args) {
      JXCollapsiblePane top = new JXCollapsiblePane() {

      @Override
      public Dimension getMaximumSize()

      { return getPreferredSize(); }

      };
      top.add(new JLabel("some random label"));
      top.add(new JLabel("and another"));
      top.add(new JButton(top.getActionMap().get(
      JXCollapsiblePane.TOGGLE_ACTION)));
      top.setCollapsed(true);
      JXFrame frame = new JXFrame("collapsible in top", true);

      frame.setLayout(new MigLayout("fill"));

      frame.add(top, "cell 0 0, grow");

      frame.add(new JScrollPane(new JXTable(50, 4)), "cell 0 1, grow");

      frame.add(new JButton(top.getActionMap().get(
      JXCollapsiblePane.TOGGLE_ACTION)), "cell 0 2, grow");

      frame.pack();
      frame.setVisible(true);
      }

      Thanks,
      Shant

      Show
      sbozian added a comment - Hi Jeanette, I read your post at: http://stackoverflow.com/questions/8434177/jxcollapsiblepane-from-swingx-not-working-correctly and tried your sample with the getMaximumSize() override, and got your point. However, while it worked with BoxLayout, the getMaximumSize override didn't solve my problem with MigLayout's 'grow' constraint. I modified your example to use MigLayout, as follows. public static void main(String[] args) { JXCollapsiblePane top = new JXCollapsiblePane() { @Override public Dimension getMaximumSize() { return getPreferredSize(); } }; top.add(new JLabel("some random label")); top.add(new JLabel("and another")); top.add(new JButton(top.getActionMap().get( JXCollapsiblePane.TOGGLE_ACTION))); top.setCollapsed(true); JXFrame frame = new JXFrame("collapsible in top", true); frame.setLayout(new MigLayout("fill")); frame.add(top, "cell 0 0, grow"); frame.add(new JScrollPane(new JXTable(50, 4)), "cell 0 1, grow"); frame.add(new JButton(top.getActionMap().get( JXCollapsiblePane.TOGGLE_ACTION)), "cell 0 2, grow"); frame.pack(); frame.setVisible(true); } Thanks, Shant
      Hide
      kleopatra added a comment -

      Hi Shant,

      thanks for the example

      This issue most probably boils down to "not supported" - and there is no obvious way to support it that I can think of: collapsible relies on the layoutManager laying out the component at its prefsize always.

      That fact is documented, so changing the type of this to improvement and lower priority.

      Ideas for a solution are welcome, of course

      Show
      kleopatra added a comment - Hi Shant, thanks for the example This issue most probably boils down to "not supported" - and there is no obvious way to support it that I can think of: collapsible relies on the layoutManager laying out the component at its prefsize always. That fact is documented, so changing the type of this to improvement and lower priority. Ideas for a solution are welcome, of course

        People

        • Assignee:
          Karl Schaefer
          Reporter:
          sbozian
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated: