user2889419
user2889419

Reputation:

Remove JInternalFrame default title bar

I'm trying to remove the title bar of a JInternalFrame, I tried this.

void remove_title_bar(){
        putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
        getRootPane().setWindowDecorationStyle(JRootPane.NONE);
    BasicInternalFrameTitlePane titlePane =  
            (BasicInternalFrameTitlePane) ((BasicInternalFrameUI) this.getUI()).  
            getNorthPane();
        this.remove(titlePane);
        this.setBorder(null);
        //this.setUI(null); doesn't work either
    }

It doesn't remove the title bar, it clears it, I mean I see the title bar blank(a white rectangle at top).
How can I remove it?

Upvotes: 1

Views: 2436

Answers (1)

user2889419
user2889419

Reputation:

Well I found this code, and yes it works(at least for me).
Please tell me if it's not a good method.

    void remove_title_bar(){
        putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
        getRootPane().setWindowDecorationStyle(JRootPane.NONE);
        ((BasicInternalFrameUI) this.getUI()).setNorthPane(null);
        this.setBorder(null);
    }

Upvotes: 3

Related Questions