To all the GUI Masters,
I have two questions,
1) How do I make my frame start/appear in the middle of the screen ?
2) How do I disable the control/menu box i.e the maximize,minimize,close options on the top left corner of the frame ?
Wating for a favorable Reply.

Centering the window:

// Center the window
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        frame.setLocation((screenSize.width - frameSize.width) / 2,
                          (screenSize.height - frameSize.height) / 2);

turns off resizing of the frame (which also disables the maximise option).


Add this to your frame constructor to remove all windows decorations (including the system menu, window borders, window title bar, etc. etc.).
I don't think you can remove these one by one in Java (but others may know a way).

On the resizing part, I don't think that disables the minimize and maximize. I believe that only makes it to were you can't drag it out bigger. I know that's one thing you wanted, but to disable max and min:


I could be wrong about that, but I'm thinking I'm right.

if you disable resize the maximise (which is a resize operation) button is disabled.
Minimise (which is not a resize operation as it simply hides the window) remains enabled.

This article has been dead for over six months. Start a new discussion instead.