Question

I have a JSplitPane with a vertical split. The top component is a table which is in a JScrollPane, and the bottom component is a detailed description of a row. The bottom component always have the same number of elements, so essentially it stays the same height.

Right now, I am using setDividerLocation to position where the pane is being split. If I put 100 into it, the top portion will be 100px, if 500 then the top will be 500px. But if I re-size the JFrame, then the top component is still 100px and the bottom component is really big.

I was wondering if there is a way to set the divider location based on the bottom component instead of the top component?

Sorry if I didn't explain it well, if what I said is still confusing, please let me know and I can try to explain it better.

------ EDIT ------

Thanks to ControlAltDel for figuring it out. This is what my code looks kinda looks like now:

JSplitPane splitPane = new JSplitPane();
splitPane.setTopComponenet(new JTable());
splitPane.setBottomComponent(new JPanel());
splitPane.setResizeWeight(1); // This gives the top component priority when the window is resized
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top