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

Turning on "TitlePane.unifiedBackground" causes JInternalFrame menu bars to become translucent #274

Closed
grimlock81 opened this issue Mar 22, 2021 · 1 comment
Labels
custom window decorations Related to using FlatLaf custom window decorations
Milestone

Comments

@grimlock81
Copy link

I've been testing the new Unified backgrounds on Windows 10 feature. When I enable it as suggested with

UIManager.put( "TitlePane.unifiedBackground", true );

I find that the whole menu bar of any JInternalFrame become translucent and I can see beneath them to whatever is lying underneath. I've tried a few themes and they all have had it so I don't think it's related to any particular theme.

See this video

Test code below

import com.formdev.flatlaf.intellijthemes.FlatArcIJTheme;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;


public class TestTitlePaneUnifiedBackground {
    public static void main(String[] args) throws Exception {
        // comment this out and the bug no longer happens
        UIManager.put("TitlePane.unifiedBackground", true);
        EventQueue.invokeLater(() -> {
            try {
                startGUI();
            }
            catch (Exception e) {
                e.printStackTrace();
            }
        });
    }

    private static void startGUI() throws Exception {
        try {
            UIManager.setLookAndFeel(new FlatArcIJTheme());
//            UIManager.setLookAndFeel(new FlatMonocaiIJTheme());
        }
        catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        }

        JFrame frame = new JFrame("Test Title Pane Unified Background");
        JDesktopPane desktopPane = new JDesktopPane();
        frame.add(desktopPane, BorderLayout.CENTER);

        JInternalFrame treeFrame1 = createInternalFrame("Test Tree 1");
        treeFrame1.setJMenuBar(createMenuBar("Tree", "Copy", "Paste", "Options"));
        desktopPane.add(treeFrame1);
        desktopPane.getDesktopManager().activateFrame(treeFrame1);
        JInternalFrame treeFrame2 = createInternalFrame("Test Tree 2");
        treeFrame2.setJMenuBar(createMenuBar("Menu", "Something", "Other", "Settings", "Blah"));
        desktopPane.add(treeFrame2);
        desktopPane.getDesktopManager().activateFrame(treeFrame2);

        frame.setJMenuBar(createMenuBar("File", "Edit", "View", "Help"));

        frame.setPreferredSize(new Dimension(800, 600));
        frame.pack();
//        frame.setExtendedState(Frame.MAXIMIZED_BOTH);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    private static JInternalFrame createInternalFrame(String title) throws Exception {
        JInternalFrame internalFrame = new JInternalFrame(title, true, true, true, true);
        internalFrame.add(new JScrollPane(new JTree()));
        internalFrame.setBounds(0, 0, 800, 600);
        internalFrame.setMaximum(true);
        internalFrame.setSelected(true);
        internalFrame.setVisible(true);
        return internalFrame;
    }

    private static JMenuBar createMenuBar(String... menuNames) {
        JMenuBar menuBar = new JMenuBar();
        for (String name : menuNames) {
            menuBar.add(new JMenu(name));
        }

        return menuBar;
    }
}
DevCharly added a commit that referenced this issue Mar 23, 2021
…f `TitlePane.unifiedBackground` is `true` (issue #274)
@DevCharly
Copy link
Collaborator

Thx. Fixed in main branch.

@DevCharly DevCharly added this to the 1.1.1 milestone Mar 23, 2021
@DevCharly DevCharly added the custom window decorations Related to using FlatLaf custom window decorations label Mar 25, 2021
DevCharly added a commit that referenced this issue Dec 14, 2021
… internal frame if it contains non-opaque components (better fix for issue #274)
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

2 participants