FlatLaf icon indicating copy to clipboard operation
FlatLaf copied to clipboard

Blinking Title Position in the TitleBar

Open VISTALL opened this issue 10 months ago • 2 comments

Hello. Title inside the title bar sometimes change position on window resize (or changing title)

Check video, and take a closer look to title

https://drive.google.com/file/d/1yqdf5MlE6YqRgatShJUZabeqU-BThTGp/view?usp=sharing

package untitled;

import com.formdev.flatlaf.FlatLightLaf;

import javax.swing.*;

public class FlatLatTItledPaneTest {
    public static void main(String[] args) {
        FlatLightLaf.setup();

        String[] titles = new String[]{"untitled", "untitled - some file - Consulo App"};
        int[] index = new int[1];

        SwingUtilities.invokeLater(() -> {
            JFrame frame = new JFrame();
            frame.setTitle(titles[0]);
            JMenuBar bar = new JMenuBar();
            frame.setJMenuBar(bar);


            bar.add(new JMenu("File"));
            bar.add(new JMenu("Edit"));
            bar.add(new JMenu("View"));
            bar.add(new JMenu("Navigate"));
            bar.add(new JMenu("Code"));
            bar.add(new JMenu("Refactor"));
            bar.add(new JMenu("Build"));
            bar.add(new JMenu("Run"));
            bar.add(new JMenu("Tools"));
            bar.add(new JMenu("Git"));
            bar.add(new JMenu("Window"));
            bar.add(new JMenu("Help"));

            frame.setSize(1250, 700);
            frame.setLocationRelativeTo(null);
            frame.setLocationByPlatform(false);

            JPanel panel = new JPanel();
            frame.add(panel);

            JButton button = new JButton("Cut/Large Title");
            button.addActionListener(e -> {
                index[0] ++;

                frame.setTitle(titles[index[0] % 2]);
            });
            panel.add(button);

            frame.setVisible(true);
        });
    }
}

VISTALL avatar May 07 '25 16:05 VISTALL

This is normal behavior.

If possible, then title is centered horizontally within window bounds:

Image

Image

If this is not possible because the window is smaller or the menu bar large, then the title is centered in the free area between menu bar and min/max/close buttons:

Image

DevCharly avatar May 17 '25 17:05 DevCharly

That's strange. Is it possible to force centralize title inside free space between menubar and titlebar buttons??

VISTALL avatar May 17 '25 18:05 VISTALL