Window containing SplitPanel will not expand

Hi everyone,

I know I’m missing something easy here, but every various combination of setExpandRatio() and setSizeFull() on the various components below does not expand my window properly. I’m creating a JFreeChart with an attached legend and I would like the window to automatically accommodate both components.

I’ve attached good and bad images to show you more what I mean.

Here’s the relevant code. My class extends VerticalLayout.

public RdpGraphWindow(RdpTable table, OceanExplorer app, boolean useUnclassified, Comparable type) {

public void showWindow() {
        Window window = new Window("RDP Classification");
        VerticalLayout windowLayout = (VerticalLayout) window.getContent();
//        windowLayout.setSizeUndefined();
        window.setHeight(600, Embedded.UNITS_PIXELS);

        legendPanel = new Panel("Legend");

        split = new SplitPanel();

        JFreeChartWrapper wrapper = new JFreeChartWrapper(createChart(), JFreeChartWrapper.RenderingMode.PNG);

Can someone please offer some suggestions on how to get this window to expand properly? I’ve been through the docs the best I can, but I’m obviously missing something.


How should it expand when it expands “properly”? I can’t really come up how it should look to look good in that very narrow window. Someone may be able to help if you describe what you want a little closer.

I guess this wasn’t too clear. The idea is that I want the window to automatically accommodate the components when they are added rather than having to specify some arbitrary size of the window (e.g., 75% x 600px). When I attempt to have everything autosize (seemingly every combination of setSizeFull() and setSizeUndefined()), it looks like the bottom image. I would like it to look like the top image without having to specificy a size for the window with the size being automatically determined by the sizes of the components.

I realize I’m missing something and need a shove in the right direction. Any takers?


Okay, now I see what you’re looking after. The window and it’s content has to be of undefined size to look correct. Off the top of my head I could guess that you have a vertical layout between the window and the splitpanel. A window has by default a vertical layout inside of it which will stack all components you add, and this will happen if you just create a window and use addComponent(split) instead of setContent(split).

The key to get the window sized correctly is to put the window, the splitpanel and the layer in between if there is any to undefined size.

I’ll try to make a working test case for you, but thought I could (possibly) point to the right direction.

Hmm… this wasn’t as straight forward as I expected. I coded an subwindow that looked about the same way as yours. I worked great as long as the components was in a HorizontalLayout, but I got that same small window at the time I switched it to a SplitPanel. I guess it is because the panel has the ability to support scrolling and that you can change the size ratios by dragging the splitter. Seems like for these reasons the splitpanel doesn’t take into account the size of its’ subcomponents. The height seemed to be right for me so it seems that the problem just lies in the direction of the splitter (here, the width).

I have to think a little bit to find a better solution. On the other hand, I don’t see any strong arguments to use the splitpanel instead of a HorizontalLayout if you want both components to be fully visible. Only reason I see is that you want the components to resize as you adjust the splitter - and in that case the components has to have setsizefull and can’t tell the splitpanel how much space it needs (as it changes).

This is a limitation/bug in SplitPanel, it doesn’t support undefined sizes on itself (i.e. doesn’t size itself according to the contained components).

I recommend creating a
bug report
for this, if you really need it.