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.
Regards.
Max

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);
        frame.setVisible(true);
frame.setResizable(false);

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

this.setUndecorated(true);

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:

setMaximizable(false);
setMinimiazable(false);


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.

O.K., I just wasn't sure.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.