Showing dialogs on top of CGrid behave funny

Hello again,

some days ago I stumbled about a “funny” behaviour when displaying a simple dialog on top of a CGrid. Please see this little demo:

private static JFrame frame;

public static void main(String[] args) {
    frame = new JFrame("title");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    CControl control = new CControl(frame);
    CContentArea contentarea = control.getContentArea();

    DefaultSingleCDockable d1 = new DefaultSingleCDockable("d1", "d1");
    d1.addAction(new DialogButton());

    CGrid grid = new CGrid(control);
    grid.add(0, 0, 1, 1, d1);
    contentarea.deploy(grid);

    frame.add(contentarea);
    frame.setBounds(500, 250, 500, 500);
    frame.setVisible(true);
}

public static final class DialogButton extends CButton {

    public DialogButton() {
        this.setShowTextOnButtons(true);
        this.setText("Show Dialog");
    }

    @Override
    protected void action() {
         //JOptionPane.showMessageDialog(frame, "Dialogs are super.");
        JOptionPane.showMessageDialog(null, "Dialogs can be funny.");
    }

}

When pressing the CButton “Show Dialog” the dialog appears completely normal, when giving a parent paramter (“frame”). Being lazy and setting it to “null” the dialog appears vibrating on and off for about 10 times.

Any comments on this ???

Thanks Thilo

I haven’t started your application (yet), but I would not be surprised if the focus management of DockingFrames is responsible. It does try to “repair” the focus about 10 times befor giving up…

I would suggest to always set a parent for dialogs, they tend to do strange things without.

Sure - you’re right telling me that “null” parameters are to be avoided. But I am still wondering why the docking component wants to have the focus back after clicking a CButton …

BTW: When dismissing the dialog and clicking “Show Dialog” a second time every thing behaves fine.

Thilo