-
-
Notifications
You must be signed in to change notification settings - Fork 280
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
JLayeredPane overlaps the title bar with FlatLaf #658
Comments
The reason is that the FlatLaf window title bar and the menu bar are children of the layered pane. This is normal/expected behavior when using FlatLaf window decorations on Windows 10/11 (or on Linux). It is the same with Metal L&F when using Theoretically it would be possible to add the title bar to the root pane and make the layered pane smaller. To fix the problem in your application, you could add another
Glass pane:
|
I understand the technical reasons, I can live with the fact that we can hover over the title bar. But this is not the main issue! Once the component is over the title bar, it cannot be dragged out anymore because the title bar (which is under it) seems to capture the events! |
If you add another
That's because dragging frame/dialog is done by Windows (and not Java). FlatLaf tells Windows that the mouse location is at a It is possible to specify special areas (e.g. for menu bar and iconfify/maximize/close buttons) that Windows should ignore and pass mouse events to Java. Following patch also added internal frame to those special areas: 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 93fe344c..a49a5835 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
@@ -57,6 +57,7 @@ import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
+import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
@@ -952,6 +953,13 @@ public class FlatTitlePane
}
}
+ // allow internal frames in layered pane to be moved/resized when placed over title bar
+ for( Component c : rootPane.getLayeredPane().getComponents() ) {
+ r = (c instanceof JInternalFrame) ? getNativeHitTestSpot( (JInternalFrame) c ) : null;
+ if( r != null )
+ hitTestSpots.add( r );
+ }
+
Rectangle minimizeButtonBounds = boundsInWindow( iconifyButton );
Rectangle maximizeButtonBounds = boundsInWindow( maximizeButton.isVisible() ? maximizeButton : restoreButton );
Rectangle closeButtonBounds = boundsInWindow( closeButton ); The red rectangle show the special area. It is larger than the internal frame because it includes areas to resize the internal frame: If this helps for your application, we can add this patch. But this works only if your application also uses internal frames... |
|
Ok, then I'll apply the patch.
I've considered this, but I think it is too risky... |
…child of `JLayeredPane` and overlaps FlatLaf title bar (issue #658)
fixed in latest |
We have some components in the layered pane which we can move around. I noticed that they could be dragged over the FlatLaf title bar. Worse, once they float over the title bar, they cannot be dragged again! 😉
Here is a test case to show what I mean:
LayeredPaneTest.zip
Note that this does not happen with Windows system look and feel. I think the root cause is that the layered pane overlaps the FlatLaf title bar. I wonder if other components (like glasspane, etc.) have a similar behavior.
The text was updated successfully, but these errors were encountered: