From b804463b738e5235f97ae12ecab271e0a2ae6e5d Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Tue, 6 Feb 2024 11:30:11 +0100 Subject: [PATCH] Window decorations: - fixed updating of client property `FULL_WINDOW_CONTENT_BUTTONS_BOUNDS` when resizing window - fixed title bar buttons placeholder debug painting --- .../main/java/com/formdev/flatlaf/ui/FlatTitlePane.java | 9 ++++++--- .../com/formdev/flatlaf/ui/FullWindowContentSupport.java | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java index 01cb991f7..82f5a22b6 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java @@ -359,11 +359,14 @@ public Dimension getPreferredSize() { buttonPanel.add( maximizeButton ); buttonPanel.add( restoreButton ); } - buttonPanel.addComponentListener( new ComponentAdapter() { + buttonPanel.add( closeButton ); + + ComponentListener l = new ComponentAdapter() { @Override public void componentResized( ComponentEvent e ) { updateFullWindowContentButtonsBoundsProperty(); } @Override public void componentMoved( ComponentEvent e ) { updateFullWindowContentButtonsBoundsProperty(); } - } ); - buttonPanel.add( closeButton ); + }; + buttonPanel.addComponentListener( l ); + addComponentListener( l ); } protected JButton createButton( String iconKey, String accessibleName, ActionListener action ) { diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FullWindowContentSupport.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FullWindowContentSupport.java index 87950f32e..d5e080b95 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FullWindowContentSupport.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FullWindowContentSupport.java @@ -209,9 +209,11 @@ private static void debugPaintRect( Graphics g, Rectangle r ) { g.drawRect( r.x, r.y, r.width - 1, r.height - 1 ); // draw diagonal cross + int x2 = r.x + r.width - 1; + int y2 = r.y + r.height - 1; Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g ); - g.drawLine( r.x, r.y, r.width - 1, r.height - 1 ); - g.drawLine( r.x, r.height - 1, r.width - 1, r.y ); + g.drawLine( r.x, r.y, x2, y2 ); + g.drawLine( r.x, y2, x2, r.y ); FlatUIUtils.resetRenderingHints( g, oldRenderingHints ); } }