Remove “X” button in Swing JDialog

前端 未结 6 882
时光说笑
时光说笑 2020-12-08 18:18

Is there a way to remove the close button (\"X\") from the JDialog title bar?

6条回答
  •  清歌不尽
    2020-12-08 18:41

    You can remove the whole dialog title by calling dialog.setUndecorated(true) but this means that the dialog can't be moved anymore.

    You can also execute dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE) to prevent that the button does anything.

    Besides that, I don't think that there's a way to remove the X completely.

提交回复
热议问题