singleton for JDialog

Hello

In my JFrame, I have button. When i click this button, a JDialog will be shown. As I set modal to false - I can access to both the main frame and the dialog. However, if i click the button second time (accidently), a new dialog will be shown. What I want is that if there is one JDialog, i donot want to have the second.

my code for displaying the dialog:

private void myBtnActionPerformed(java.awt.event.ActionEvent evt) {

(new NewDialog(this, false)).show();

}

Thank you for any help

shuhu

[546 byte] By [shoaa] at [2007-11-27 8:15:42]
# 1

The answer is right there in the question. Use singeton pattern.

public class TestJDialog {

private static TestJDialog dialog = new TestJDialog();

public static TestJDialog getInstance() {

return dialog;

}

TestJDialog() {

// code for creating dialog

}

}

haishaia at 2007-7-12 20:00:31 > top of Java-index,Desktop,Core GUI APIs...
# 2
i had the same problem ....now it is solved but i have one more requirement When a button is pressed a dialog is created .Now when this dialog is minimized and i press that button again ,this dialog should be restored.
sunnyjaina at 2007-7-12 20:00:31 > top of Java-index,Desktop,Core GUI APIs...
# 3
Hi Use this code for restoring the minimised dialog/frame to restore. if(objFrame!= null){objFrame.setVisible(true);objFrame.setState(java.awt.Frame.NORMAL);}
sureshsarmaa at 2007-7-12 20:00:31 > top of Java-index,Desktop,Core GUI APIs...
# 4
HII think the code you have given is for restoring a Frame , while in need to do it for Dialog.
sunnyjaina at 2007-7-12 20:00:31 > top of Java-index,Desktop,Core GUI APIs...