0

I have a CustomDialog that extends JDialog.

In its constructor I have

setModalityType(ModalityType.APPLICATION_MODAL);

setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

They dont seem to work well together: i think the Modality stucks the defaultcloseoperation, and in the end i have to click twice the X in order to get the CustomDialog closed.

How should i act to obtain both

1- always on-top visualization (i use application_modal for this)

2- dispose on close

alessiop86
  • 1,285
  • 2
  • 19
  • 38

2 Answers2

2

It works for me:

dialog.setModal(true);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
Daniel Cisek
  • 931
  • 3
  • 9
  • 23
  • I have to click twice the X button in order to close the Jdialog. As far as i Click the first time, seems like nothing happens – alessiop86 Oct 10 '12 at 21:33
1

I answer to provide people who have the same "click the X twice in order to close" behaviour a future reference.

My issue was related to a double setVisible(true), one in the constructor and one in a "initializer" function.

With only 1 setVisible(true), the issue is gone

alessiop86
  • 1,285
  • 2
  • 19
  • 38