1
votes

I have done my own version of the PropertyCross Demo (provided in their demo section).

The problem I currently face is the size of the "Recent Search" area. While I have a non-scrollable container, I can easily define the preferred height. As the Box Layout adheres to the preferred size, all is well, with the little issue of not being able to scroll it and see more than one result:

recentSearchContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS)); recentSearchContainer.setPreferredH((int)(this.getContentP‌​ane().getHeight() * 0.1f));

Once I set the container to scrollable, the preferred height gets overwritten and takes up as much space as it needs, taking too much space from the BorderLayout Center piece above it.

How to manipulate the preferred size of scrollable components?

Location Search button is not visible.

2

2 Answers

1
votes

You don't manipulate the preferred size. Scrollables take up more space so if you need them to take up a specific amount of space you need to use the right type of layout which in this case might not be border layout...

Border layout gives NORTH/SOUTH elements their preferred height which might not be what you want. You might want a grid layout which will divide the height 50/50. You might want a table layout where you can define the height in percentages etc.

1
votes

For those who are interested, here is the solution:

  1. Setup a table layout with a single column and as many rows as you need (similar to box layout y axis or border layout which only north, center and south).

  2. Set the table layout to non-scrollable so it defaults to 100% of your screen.

  3. add the components with height % of the screen they should take up.

  4. those components can be scrollable and will still stick to the height constraint!

    // inside a form object, setup the layout
    TableLayout tl = new TableLayout(3, 1);
    tl.setGrowHorizontally(true);
    setScrollable(false);
    setLayout(tl);
    ...
    // and add stuff to it
    add(tl.createConstraint().heightPercentage(15), labelDesc);
    add(tl.createConstraint().heightPercentage(50), compGroup);
    add(tl.createConstraint().heightPercentage(35), recentSearchContainer);
    

Works like a charm!