Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
8310054: ScrollPane insets are incorrect
Browse files Browse the repository at this point in the history
Reviewed-by: honkar, prr
Backport-of: d6c2ee3448a14b3e5a392aacc11ed8e47d388f80
  • Loading branch information
aivanov-jdk committed Jun 20, 2023
1 parent e0cc401 commit beb0d95
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
@@ -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
Expand All @@ -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;

Expand Down Expand Up @@ -105,7 +111,6 @@ public void childResized(int width, int height) {
ScrollPane sp = (ScrollPane)target;
Dimension vs = sp.getSize();
setSpans(vs.width, vs.height, width, height);
setInsets();
}

synchronized native void setSpans(int viewWidth, int viewHeight,
Expand Down
Expand Up @@ -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);
Expand Down Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/awt/ScrollPane/ScrollPaneExtraScrollBar.java
Expand Up @@ -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
Expand Down Expand Up @@ -57,7 +57,7 @@ public void init() throws Exception {
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);
});
Expand Down

1 comment on commit beb0d95

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.