Look and Feel with window decoration

If you set the following two lines at the beginning of the main method of an application (for instance: Size and Color sample):
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);

Run the application, then select the metal Look and Feel and play a while (minimize, externalize, normalize) and you will get:

Exception in thread “AWT-EventQueue-0” java.lang.StackOverflowError
at sun.awt.X11.XGlobalCursorManager.getCursorManager(XGlobalCursorManager.java:47)
at sun.awt.X11.XComponentPeer.updateCursorImmediately(XComponentPeer.java:833)
at java.awt.Component.updateCursorImmediately(Component.java:2943)
at java.awt.Component.setCursor(Component.java:2924)
at java.awt.Window.setCursor(Window.java:1258)
at javax.swing.plaf.metal.MetalRootPaneUI$MouseInputHandler.mouseExited(MetalRootPaneUI.java:884)
at java.awt.Component.processMouseEvent(Component.java:6294)
at java.awt.Component.processEvent(Component.java:6053)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Window.processEvent(Window.java:1836)
at java.awt.Component.dispatchEventImpl(Component.java:4651)
at java.awt.Container.dispatchEventToSelf(Container.java:2123)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4566)
at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4358)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4481)
at bibliothek.gui.dock.security.GlassedPane$GlassPane.send(GlassedPane.java:371)
at bibliothek.gui.dock.security.GlassedPane$GlassPane.send(GlassedPane.java:279)
at bibliothek.gui.dock.security.GlassedPane$GlassPane.mouseEntered(GlassedPane.java:247)
at java.awt.Component.processMouseEvent(Component.java:6297)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6053)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4651)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4366)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4481)
at bibliothek.gui.dock.security.GlassedPane$GlassPane.send(GlassedPane.java:371)
at bibliothek.gui.dock.security.GlassedPane$GlassPane.send(GlassedPane.java:279)
at bibliothek.gui.dock.security.GlassedPane$GlassPane.mouseEntered(GlassedPane.java:247)

or

Exception in thread “AWT-EventQueue-0” java.lang.StackOverflowError
at bibliothek.gui.dock.station.OverpaintablePanel$Overlay.contains(OverpaintablePanel.java:279)
at java.awt.Container.getMouseEventTargetImpl(Container.java:2205)
at java.awt.Container.getMouseEventTarget(Container.java:2168)
at java.awt.Container.getMouseEventTargetImpl(Container.java:2216)
at java.awt.Container.getMouseEventTarget(Container.java:2168)
at java.awt.Container.getMouseEventTargetImpl(Container.java:2216)
at java.awt.Container.getMouseEventTarget(Container.java:2168)
at java.awt.Container.getMouseEventTargetImpl(Container.java:2216)
at java.awt.Container.getMouseEventTarget(Container.java:2168)
at java.awt.Container.getMouseEventTargetImpl(Container.java:2216)
at java.awt.Container.getMouseEventTarget(Container.java:2168)
at java.awt.Container.getMouseEventTargetImpl(Container.java:2216)
at java.awt.Container.getMouseEventTarget(Container.java:2168)
at java.awt.Container.getMouseEventTargetImpl(Container.java:2216)
at java.awt.Container.getMouseEventTarget(Container.java:2168)
at java.awt.Container.getMouseEventTarget(Container.java:2131)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4216)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4481)
at bibliothek.gui.dock.security.GlassedPane$GlassPane.send(GlassedPane.java:371)
at bibliothek.gui.dock.security.GlassedPane$GlassPane.send(GlassedPane.java:279)
at bibliothek.gui.dock.security.GlassedPane$GlassPane.mouseEntered(GlassedPane.java:247)
at java.awt.Component.processMouseEvent(Component.java:6297)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6053)

In my application, with Metal or Substance Look and Feel and window decoration, I cannot resize window or the size of window becomes random when resizing. The issue seems to be related with the “normalize” mode of CDockable.

Best regards,

Nicolas

Actually, the issue is not the decoration, but the fact that a MouseListener is added to the JFrame. This MouseListener however does not consume the MouseEvent, instead the JFrame retargets the event to the GlassedPane - which in returns retargets the event to the JFrame. I’ll add some code in the next release to stop this cycle.

In my application, with Metal or Substance Look and Feel and window decoration, I cannot resize window or the size of window becomes random when resizing

Actually I could produce a similar bug by… doing exactly nothing. My test application below has issues being resized, it just jumps around while I resize it. So I would say this is a bug of Swing, not related to DockingFrames and thus cannot be fixed by me.


import javax.swing.JDialog;
import javax.swing.JFrame;

public class WindowResizeTest {
	public static void main( String[] args ){
		JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);
        
        JFrame frame = new JFrame();
        frame.setBounds( 20, 20, 400, 400 );
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        frame.setVisible( true );
	}
}

[QUOTE=Beni]

Actually I could produce a similar bug by… doing exactly nothing. My test application below has issues being resized, it just jumps around while I resize it. So I would say this is a bug of Swing, not related to DockingFrames and thus cannot be fixed by me.


import javax.swing.JDialog;
import javax.swing.JFrame;

public class WindowResizeTest {
	public static void main( String[] args ){
		JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);
        
        JFrame frame = new JFrame();
        frame.setBounds( 20, 20, 400, 400 );
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        frame.setVisible( true );
	}
}
```[/QUOTE]

You're right, I just think it was not possible. This feature is clearly buggy on all the OS.

I think it is better to avoid using "JFrame.setDefaultLookAndFeelDecorated(true)". With JDialog it seems Ok.