setLocation(parent.getLocation().x + parent.getSize().width/2 - getSize().width/2, parent.getLocation().y + parent.getSize().height/2 - getSize().height/2);
Dimension size = getSize(); boolean updateSize = false; if ( size.width < Settings.minimumSizeWidth ) { size.width = Settings.minimumSizeWidth; } if ( size.height < Settings.minimumSizeHeight ) { size.height = Settings.minimumSizeHeight; } if ( updateSize ) { setSize( size ); size = getSize(); } setLocation(parent.getLocation().x + parent.getSize().width/2 - size.width/2, parent.getLocation().y + parent.getSize().height/2 - size.height/2);
    public SingleChoiceDialog(Frame parent, String title,                        String question, String[] choices)    {        super(parent, title, true);        super.setResizable(false);        GridBagLayout gridbag = new GridBagLayout();        setLayout(gridbag);        GridBagConstraints c = new GridBagConstraints();        c.gridwidth = 1;        c.gridheight = 1;        c.gridx = 0;        // Display the question in a scrollable, uneditable area.        TextArea message = new TextArea(question, 5, 50, TextArea.SCROLLBARS_VERTICAL_ONLY);        message.setEditable(false);        c.gridy = 0;        c.insets = new Insets(0, 5, 0, 5);        add(message,c);        // Do we have any choices?        if ( choices != null && choices.length > 0 ) {            // Display the choices as a single column of radio buttons.            // The first checkbox is selected by default.            Panel choiceArea = new Panel( new GridLayout(0, 1) );            c.gridy++;            c.insets = new Insets(0, 5, 0, 5);            // If there are many choices, display them in a scroll pane.            if ( choices.length > 5 ) {                // Save the current value of c.fill; change it to HORIZONTAL.                int saveFill = c.fill;                c.fill = GridBagConstraints.HORIZONTAL;                // Place the choice area in the center                // of another panel that is scrolled.                ScrollPane scroller = new ScrollPane();                Panel scrollee = new Panel( new GridBagLayout() );                GridBagConstraints center = new GridBagConstraints();                center.anchor = GridBagConstraints.CENTER;                scrollee.add( choiceArea, center );                scroller.add( scrollee );                add( scroller, c );                // Restore the saved value of c.fill.                c.fill = saveFill;            } else {                add( choiceArea, c );            }            CheckboxGroup radioGroup = new CheckboxGroup();            this.checkboxes = new Checkbox[ choices.length ];            for ( int loop = 0; loop < choices.length; loop++ ) {                this.checkboxes[loop] = new Checkbox( choices[loop],                                                      (loop == 0),                                                      radioGroup );                choiceArea.add( this.checkboxes[loop] );            }        } // End have-choices        // Allow the user to confirm or abort the choice.        setupButtons();        c.gridy++;        c.insets = new Insets(5, 5, 5, 5);        add(panButtons,c);        butOK.requestFocus();                addWindowListener(new WindowAdapter() {                public void windowClosing(WindowEvent e) { setVisible(false); }            });                pack();        setLocation(parent.getLocation().x + parent.getSize().width/2 - getSize().width/2,                    parent.getLocation().y + parent.getSize().height/2 - getSize().height/2);    };