8310054: ScrollPane insets are incorrect

Reviewed-by: honkar, prr
This commit is contained in:
Alexey Ivanov
2023-06-16 17:24:07 +00:00
parent 4eb4f20ae2
commit d6c2ee3448
3 changed files with 12 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,13 @@
*/
package sun.awt.windows;
import java.awt.*;
import java.awt.Adjustable;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Point;
import java.awt.ScrollPane;
import java.awt.ScrollPaneAdjustable;
import java.awt.event.AdjustmentEvent;
import java.awt.peer.ScrollPanePeer;
@@ -105,7 +111,6 @@ final class WScrollPanePeer extends WPanelPeer implements ScrollPanePeer {
ScrollPane sp = (ScrollPane)target;
Dimension vs = sp.getSize();
setSpans(vs.width, vs.height, width, height);
setInsets();
}
synchronized native void setSpans(int viewWidth, int viewHeight,

View File

@@ -525,6 +525,7 @@ void AwtScrollPane::_SetSpans(void *param)
parentWidth, parentHeight, childWidth, childHeight);
s->RecalcSizes(parentWidth, parentHeight, childWidth, childHeight);
s->VerifyState();
s->SetInsets(env);
}
ret:
env->DeleteGlobalRef(self);
@@ -718,7 +719,7 @@ Java_sun_awt_windows_WScrollPanePeer_setInsets(JNIEnv *env, jobject self)
{
TRY
AwtToolkit::GetInstance().SyncCall(AwtScrollPane::_SetInsets,
AwtToolkit::GetInstance().InvokeFunction(AwtScrollPane::_SetInsets,
env->NewGlobalRef(self));
// global ref is deleted in _SetInsets()

View File

@@ -23,7 +23,7 @@
/*
@test
@bug 4152524
@bug 4152524 8310054
@requires os.family=="windows"
@summary Test that scroll pane doesn't have scroll bars visible when it is
shown for the first time with SCROLLBARS_AS_NEEDED style
@@ -57,7 +57,7 @@ public class ScrollPaneExtraScrollBar {
sp = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
sp.add(new Button("TEST"));
f.add("Center", sp);
f.pack();
// Frame must not be packed, otherwise the bug isn't reproduced
f.setLocationRelativeTo(null);
f.setVisible(true);
});