Undecorated frame/dialog with default border (Windows 11 only)
Hello. IntelliJ IDEA use same hack as for default frame. Here example:
Code from intellij
https://github.com/JetBrains/intellij-community/blob/master/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java#L253
Don't understand what you want 😕 Provide more details...
Sorry. For now - it's impossible to set native Windows 11 border to undecorated dialog/frame.
I thought - it's limitation of undecorated windows, but - looks like its not. IntelliJ IDEA set native Windows 11 border to undecorated frame (sample screenshot and code which is set to it).
I tested with current version of FlatLaf (and removed if-undecorated-return statement) - but native library return hwnd=0, for now I'm don't known why it return 0.
Will be nice to have option for setting native border to undecorated frames/dialogs at least at Windows 11 (its limitation of IDEA too)
Thanks
... but native library return hwnd=0, for now I'm don't known why it return 0.
Then the win32 window is not yet created.
You could try to invoke window.addNotify() before getting HWND.
Or better override addNotify() and do it there.
But I don't know whether it works to apply a rounded border to an undecorated frame.
You could also hide the min/max/close buttons and use full window content mode for a decorated frame.
See client properties (e.g. JRootPane.titleBarShowIconify, etc)
https://www.formdev.com/flatlaf/client-properties/#JRootPane
And, you are right. But my fast check show dialog without border anyway. But hwnd now is set.
(always forgetting native window flow)
I known about JRootPane.titleBarShowIconify but want adopt current code, just with calling set method.
IDEA & Consulo used undecorated windows for popups like this for all. Will be nice to save this setting.
I will test today maybe - how it works at macOS (about border shadow), as I known IDEA emulate shadow border at not windows 11
Test at mac. macOS always render shadow for undecorated frame, but without rounded borders.
If I call method
FlatPopupFactory#setupRoundedBorder
we have perfect undecorated window at mac
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
FlatMacLightLaf.setup();
JFrame frame = new JFrame() {
@Override
public void addNotify() {
super.addNotify();
try {
Method method = FlatPopupFactory.class.getDeclaredMethod("setupRoundedBorder", Window.class, Component.class, Component.class);
method.setAccessible(true);
method.invoke(null, this, this, getRootPane());
} catch (Exception e) {
e.printStackTrace();
}
}
};
frame.setLocationRelativeTo(null);
frame.setSize(500, 500);
frame.setUndecorated(true);
frame.setLocation(300, 300);
frame.setVisible(true);
});
}
}
Also calling this method at Windows make good border (but without shadow)
Maybe introduce new parameter for undecorated window's which add default border - unify it between mac/windows. At linux maybe use default rectangle border with software shadow(like popups)