Skip to content

Commit

Permalink
8244400: MenuItem may cache the size and did not update it when the s…
Browse files Browse the repository at this point in the history
…creen DPI is changed

Reviewed-by: serb, aivanov
  • Loading branch information
prsadhuk committed Jan 23, 2023
1 parent 836198a commit 11aadc9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, 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 Down Expand Up @@ -1160,6 +1160,9 @@ public void propertyChange(PropertyChangeEvent e) {
// existed, and install a new one if the text installed
// into the JLabel is html source.
JMenuItem lbl = ((JMenuItem) e.getSource());
if (SwingUtilities2.isScaleChanged(e)) {
MenuItemLayoutHelper.clearUsedParentClientProperties(lbl);
}
String text = lbl.getText();
BasicHTML.updateRenderer(lbl, text);
} else if (name == "iconTextGap") {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, 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 Down Expand Up @@ -56,22 +56,19 @@
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.tree.DefaultMutableTreeNode;

import sun.swing.MenuItemLayoutHelper;

import static javax.swing.UIManager.getInstalledLookAndFeels;

/**
* @test
* @key headful
* @bug 8201552 8213843 8213535
* @bug 8201552 8213843 8213535 8244400
* @summary Initial layout of the component should use correct graphics config.
* It is checked by SwingUtilities.updateComponentTreeUI(), if layout
* was correct the call to updateComponentTreeUI() will be no-op.
* @modules java.desktop/sun.swing
* @compile -encoding utf-8 StalePreferredSize.java
* @run main/othervm/timeout=400 StalePreferredSize
* @run main/othervm/timeout=400 -Dsun.java2d.uiScale=1 StalePreferredSize
* @run main/othervm/timeout=400 -Dsun.java2d.uiScale=2.25 StalePreferredSize
* @run main/othervm/timeout=600 StalePreferredSize
* @run main/othervm/timeout=600 -Dsun.java2d.uiScale=1 StalePreferredSize
* @run main/othervm/timeout=600 -Dsun.java2d.uiScale=2.25 StalePreferredSize
*/
public final class StalePreferredSize {

Expand Down Expand Up @@ -182,10 +179,6 @@ static void checkComponent(Callable<JComponent> creator) throws Exception {
int y = frame.getY() + 200;
PopupFactory factory = PopupFactory.getSharedInstance();
popup = factory.getPopup(frame, component, x, y);
if (component instanceof JMenuItem) {
// TODO JDK-8244400
MenuItemLayoutHelper.clearUsedParentClientProperties((JMenuItem)component);
}
} else {
frame.add(new JScrollPane(component));
}
Expand Down

1 comment on commit 11aadc9

@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.