Skip to content

Commit e0c50fd

Browse files
committed
8244400: MenuItem may cache the size and did not update it when the screen DPI is changed
Backport-of: 11aadc9d98d364b91114c028c7e2eff8de2f2bf0
1 parent fc816a5 commit e0c50fd

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,9 @@ public void propertyChange(PropertyChangeEvent e) {
11161116
// existed, and install a new one if the text installed
11171117
// into the JLabel is html source.
11181118
JMenuItem lbl = ((JMenuItem) e.getSource());
1119+
if (SwingUtilities2.isScaleChanged(e)) {
1120+
MenuItemLayoutHelper.clearUsedParentClientProperties(lbl);
1121+
}
11191122
String text = lbl.getText();
11201123
BasicHTML.updateRenderer(lbl, text);
11211124
} else if (name == "iconTextGap") {

test/jdk/javax/swing/GraphicsConfigNotifier/StalePreferredSize.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -56,22 +56,19 @@
5656
import javax.swing.UnsupportedLookAndFeelException;
5757
import javax.swing.tree.DefaultMutableTreeNode;
5858

59-
import sun.swing.MenuItemLayoutHelper;
60-
6159
import static javax.swing.UIManager.getInstalledLookAndFeels;
6260

6361
/**
6462
* @test
6563
* @key headful
66-
* @bug 8201552 8213843 8213535
64+
* @bug 8201552 8213843 8213535 8244400
6765
* @summary Initial layout of the component should use correct graphics config.
6866
* It is checked by SwingUtilities.updateComponentTreeUI(), if layout
6967
* was correct the call to updateComponentTreeUI() will be no-op.
70-
* @modules java.desktop/sun.swing
7168
* @compile -encoding utf-8 StalePreferredSize.java
72-
* @run main/othervm/timeout=400 StalePreferredSize
73-
* @run main/othervm/timeout=400 -Dsun.java2d.uiScale=1 StalePreferredSize
74-
* @run main/othervm/timeout=400 -Dsun.java2d.uiScale=2.25 StalePreferredSize
69+
* @run main/othervm/timeout=600 StalePreferredSize
70+
* @run main/othervm/timeout=600 -Dsun.java2d.uiScale=1 StalePreferredSize
71+
* @run main/othervm/timeout=600 -Dsun.java2d.uiScale=2.25 StalePreferredSize
7572
*/
7673
public final class StalePreferredSize {
7774

@@ -182,10 +179,6 @@ static void checkComponent(Callable<JComponent> creator) throws Exception {
182179
int y = frame.getY() + 200;
183180
PopupFactory factory = PopupFactory.getSharedInstance();
184181
popup = factory.getPopup(frame, component, x, y);
185-
if (component instanceof JMenuItem) {
186-
// TODO JDK-8244400
187-
MenuItemLayoutHelper.clearUsedParentClientProperties((JMenuItem)component);
188-
}
189182
} else {
190183
frame.add(new JScrollPane(component));
191184
}

0 commit comments

Comments
 (0)