0

我有一个CustomDialog可以扩展的JDialog.

在其中constructor我有

setModalityType(ModalityType.APPLICATION_MODAL);

setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

它们似乎不能很好地协同工作:我认为模态卡住了defaultcloseoperation,最后我必须单击两次X才能CustomDialog关闭。

我应该如何采取行动来获得两者

1-始终在顶部可视化(我application_modal用于此)

2-关闭时处理

4

2 回答 2

2

这个对我有用:

dialog.setModal(true);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
于 2012-10-10T21:20:12.650 回答
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

于 2012-10-13T21:00:59.087 回答