On Sat, 10 Oct 2020 11:33:57 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:
>> I tried following testcase snippet >> ``` >> JRootPane r = new JRootPane(); >> JFrame f = new JFrame(); >> f.getRootPane().setUI(new MetalRootPaneUI()); >> f.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); >> f.getRootPane().getUI().installUI(r); >> r.getContentPane().add(new JLabel("foo")); >> System.out.println("Preferred Size: " + >> r.getPreferredSize()); >> but it uses JRootPane.RootLayout layout manager and not MetalRootLayout so >> it calls Rootlayout.preferredLayoutSize and not >> MetalRootLayout.preferredlayoutSize > > 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 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. ------------- PR: https://git.openjdk.java.net/jdk/pull/433