Skip to content

Apply split percentage once size is known - #49

Open
danilovesky wants to merge 1 commit into
opencollab:masterfrom
danilovesky:fix-split-proportion-on-import
Open

danilovesky wants to merge 1 commit into
opencollab:masterfrom
danilovesky:fix-split-proportion-on-import

Conversation

@danilovesky

Copy link
Copy Markdown
Contributor

Without constant percent, a split proportion set before the split pane has a size was lost (stored layouts came back at 0.5 or Swing's preferred sizes). DockingSplitPane now keeps the percentage and applies it in setBounds() once the size is known, as constant-percent mode already does.

Fixes #33

Without constant percent, JSplitPane converted the percentage to pixels
from the zero size of a split that was not laid out yet, so a stored
proportion was lost on importLayout (0.5 below 1/3, preferred sizes
from 1/3 on). Keep the percentage and apply it in setBounds() once the
size is known, as constant-percent mode does.

Fixes opencollab#33
@mergify

mergify Bot commented Nov 22, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

@danilovesky

Copy link
Copy Markdown
Contributor Author

@sylvestre This is the last "urgent" fix I wanted to make. Handling of corner cases is much more robust now: in my FlexDock-based project I used to see exceptions, unexpected size changes and even lost layout files, but not anymore.

After the remaining PRs are merged, I'd propose bumping the version to v1.4 and doing a proper release. I can prepare a PR that bumps the poms and dates the release notes; the tag and publishing would be up to you. Since a few public APIs were removed and the minimum Java version changed, v2.0 would also be defensible, so I'm happy to go with whichever you prefer.

if (constantPercent) {
setResizeWeight(percent);
super.setDividerLocation((int) (percent * getSplitSize()));
} else if (percentPending && getSplitSize() > 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if setDividerLocation(int) is called while a percentage is pending, setBounds() will still override it with the old percentage, no?
should an int location clear percentPending?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stored split proportion is ignored on importLayout without constant percent

2 participants