JFormDesigner / FlatLaf

FlatLaf - Swing Look and Feel (with Darcula/IntelliJ themes support)
https://www.formdev.com/flatlaf/
Apache License 2.0
3.42k stars 272 forks source link

Bug: setUndecorated() on JFrame or JDialog has no visual effect on Linux #586

Closed eduhoribe closed 2 years ago

eduhoribe commented 2 years ago

Sample code:

import com.formdev.flatlaf.FlatLightLaf;

import javax.swing.*;

class Scratch {
    public static void main(String[] args) {

        JFrame.setDefaultLookAndFeelDecorated(true);

        FlatLightLaf.setup();

        JFrame frame = new JFrame();
        frame.setUndecorated(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(100, 100);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

Expected result:

A JFrame/JDialog without the window decoration image

Actual result:

A JFrame/JDialog with the window decoration image

Workaround:

frame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
DevCharly commented 2 years ago

This is not a bug. This is normal behavior for look and feels that support window decorations, where LookAndFeel.getSupportsWindowDecorations() returns true.

Same happens for Metal L&F:

grafik

For L&Fs that do not support window decorations (GTK, Windows, Nimbus, etc), you indeed get an empty window.

The reason for this behavior is in JFrame.frameInit(): https://github.com/openjdk/jdk/blob/ef20ffe4d222d48f0bdba81a0b864d9fb455e9a6/src/java.desktop/share/classes/javax/swing/JFrame.java#L261-L268

eduhoribe commented 2 years ago

I see... Thank you, I'm closing the issue then.