New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4916923: In MetalRootPaneUI, MetalRootLayout does not correctly calculate minimumsize #433
Conversation
👋 Welcome back psadhukhan! A progress list of the required criteria for merging this PR into |
@@ -536,7 +536,7 @@ public Dimension minimumLayoutSize(Container parent) { | |||
} | |||
|
|||
return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth) + i.left + i.right, | |||
cpHeight + mbHeight + tpWidth + i.top + i.bottom); | |||
cpHeight + mbHeight + tpHeight + i.top + i.bottom); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to check this change by some testcase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried at the time of PR but unable to check as MetalRootLayout is private so not able to access its methods. That is why I ran all client-tier3 jtreg and jck tests, and mach5 job link is posted in JBS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the MetalRootLayout is private and it is not possible to trigger this code in other ways, then it means we can delete it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MetalRootLayout class and methods are private but it is called from MetalRootPaneUI so we cannot delete it
but I could not find any ways to invoke MetalRootLayout methods from testcase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MetalRootPaneUI installs the MetalRootLayout as a layout manager for the current JRootPane. And it should be used from the Container.preferredSize()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to set decorations for the root pane:
UIManager.setLookAndFeel(new MetalLookAndFeel());
JFrame frame = new JFrame();
frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
frame.pack();
System.out.println("Layout: " + frame.getRootPane().getLayout());
========
Layout: javax.swing.plaf.metal.MetalRootPaneUI$MetalRootLayout@69d9c55
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried with
UIManager.setLookAndFeel(new MetalLookAndFeel());
JFrame frame = new JFrame();
frame.setSize(new Dimension(500, 800));
frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
//frame.pack();
frame.setVisible(true);
System.out.println("Layout: " + frame.getRootPane().getLayout());
System.out.println("PreferredSize " + frame.getRootPane().getPreferredSize());
but it seems tpWidth and tpHeight what is being changed is the width and height of MetalTitlePane which seems always comes as 23 for both no matter what frame size is set, so I guess using any variable will do but logically, it will be good to use "tpHeight" for height calculation.
If it is believed to continue with same logical but not technical error, I will close this PR without integrating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug submitter said that it is somehow affected his application. So I assume there is a way to trigger this bug in the MetalRootLayout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From MetalTitlePane.java, the same "height" is being used for width and height so the value is same for both.
private class TitlePaneLayout implements LayoutManager {
public void addLayoutComponent(String name, Component c) {}
public void removeLayoutComponent(Component c) {}
public Dimension preferredLayoutSize(Container c) {
int height = computeHeight();
return new Dimension(height, height);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no reproducible testcase and the submitter id is not active anymore so cannot ask him and I am not sure of any other way, so if this is not accepted without a reproducing testcase, I will close this PR.
Please review a fix for an issue where minimumLayoutSize and preferredlayoutSize of MetalRootLayout class wrongly uses the width of the title pane in the height calculation:
Proposed fix is to rectify the anomaly and use tpHeight for height calculation.
All closed, open jtreg and JCK tests and SwingSet2 Metal L&F are unaffected by this change.
Progress
Issue
Download
$ git fetch https://git.openjdk.java.net/jdk pull/433/head:pull/433
$ git checkout pull/433