CodeGuy
CodeGuy

Reputation: 28907

Title bar not working properly on JInternalFrame

I have a JInternalFrame class with a constructor that looks like this:

public MyInternalFrame() {
        super("Name");
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(AutogeneFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(AutogeneFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(AutogeneFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(AutogeneFrame.class.getName()).log(Level.SEVERE, null, ex);
        }

        initComponents();

    }

The problem is that the maximize, minimize, and exit buttons that should be in the top left corner of the window do not show up. However, the title "Name" does show up in the center of the title bar. I'm on a Mac, and rather than having the three little circles (red, yellow, and green) that are in the top left corner of all windows, they just appear as three little gray circles that are not clickable

Upvotes: 1

Views: 358

Answers (2)

Catalina Island
Catalina Island

Reputation: 7126

You're constructing the JInternalFrame that "Creates a non-resizable, non-closable, non-maximizable, non-iconifiable JInternalFrame with the specified title." You want the one like this:

super("Name", true, true, true, true);

Upvotes: 2

Emmanuel Bourg
Emmanuel Bourg

Reputation: 10958

Do not call UIManager.setLookAndFeel() in the constructor of the frame. Instead do it before creating the frame and from the EDT using SwingUtilities.invokeLater().

Upvotes: 2

Related Questions