Skip to content
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

Double title bar #315

Closed
Ferdudas97 opened this issue Apr 23, 2021 · 6 comments
Closed

Double title bar #315

Ferdudas97 opened this issue Apr 23, 2021 · 6 comments
Labels
custom window decorations Related to using FlatLaf custom window decorations
Milestone

Comments

@Ferdudas97
Copy link

When we use FlatLaf.setUseNativeWindowDecorations(FlatLaf.supportsNativeWindowDecorations()); , sometimes we got two title bars (one from system and one from FlatLaf). Also when this error occurs, buttons on title bar don`t work as expected - no action after click.

The bug occurs in a non-deterministic way, so a test application has been created to reproduce it - double-title-bar-app.zip
Gif included from test app
Animation

FlatLaf version: 1.1.2
Java Version: 11
OS: Windows 10 Pro

import com.formdev.flatlaf.FlatIntelliJLaf;
import com.formdev.flatlaf.FlatLaf;

import javax.swing.*;
import java.awt.*;
import java.lang.reflect.InvocationTargetException;

public class FrameCreator {
   private static int size = 200;

   public static void initLAF() throws UnsupportedLookAndFeelException {
      UIManager.setLookAndFeel(new FlatIntelliJLaf());
      FlatLaf.setUseNativeWindowDecorations(FlatLaf.supportsNativeWindowDecorations());

      UIManager.put("TitlePane.unifiedBackground", true);
   }
   public static void main(String[] args) throws InvocationTargetException, InterruptedException {
      SwingUtilities.invokeAndWait(() -> {
         try {
            initLAF();
         } catch (UnsupportedLookAndFeelException e) {
            e.printStackTrace();
         }
      });
      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      double width = screenSize.getWidth();
      double height = screenSize.getHeight();
         for (int i = 0; i < width / size; i++) {
            for (int j = 0; j < height / size; j++) {
               showFrame(i,j);
            }
      }
   }

   public static void showFrame(int i, int j) {
      SwingUtilities.invokeLater(() -> {
         JFrame frame = new JFrame();
         frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
         frame.setSize(size - 10, size - 10);
         frame.setLocation(i * size + 10, j * size + 10);
         frame.setVisible(true);
      });
   }
}

@DevCharly
Copy link
Collaborator

That's interesting. Never seen this before. Will investigate...

Thanks for the test case. This is a great help 👍
But could you please replace the animated GIF with a static screenshot? I'm feeling hypnotized 😵

@DevCharly
Copy link
Collaborator

Turns out that subtracting HWNDs in following line is not reliable if key addresses are nearly the same (+/- 2):

Fixed in commit 9d08230
Please try the latest snapshot: https://github.com/JFormDesigner/FlatLaf#snapshots

CC @ingokegel

@DevCharly DevCharly added this to the 1.2 milestone Apr 23, 2021
@DevCharly
Copy link
Collaborator

BTW it is not necessary to invoke FlatLaf.setUseNativeWindowDecorations(FlatLaf.supportsNativeWindowDecorations()); because it is enabled by default.

DevCharly added a commit that referenced this issue Apr 23, 2021
@Ferdudas97
Copy link
Author

Thanks for quick fix.

@ireque
Copy link

ireque commented Apr 26, 2021

@DevCharly
I confirm that fix works.
Can you backport it to release version?

@DevCharly DevCharly added the custom window decorations Related to using FlatLaf custom window decorations label May 13, 2021
@DevCharly
Copy link
Collaborator

FlatLaf 1.2 is now available. Sorry for the delay...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom window decorations Related to using FlatLaf custom window decorations
Projects
None yet
Development

No branches or pull requests

3 participants