JDialog not showing minimize/close button on Linux

☆樱花仙子☆ 提交于 2019-12-12 22:31:08

问题


This question has been asked previously but from what I have found, the questions and responses are from a few years ago and hoping there is updated/new information.

The same code works on Windows as it displays the X in the top right corner. On Linux, nothing appears in the top right corner. Windows is using JDK 1.8.0_60 Linux is using 1.8.0_111-b15

Based on the research, this issue is known to exist on varying flavors of Linux.

import javax.swing.JDialog;

public class JDialogSimple{

  private JDialog dialog = new JDialog();

  public JDialogSimple() {
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setModal(true);
    dialog.pack();
    dialog.setLocation(200, 200);
    dialog.setSize(400, 400);
    dialog.setTitle("Test Dialog");
    dialog.setVisible(true);
  }

  public static void main(String args[]) {
      JDialogSimple colourDialog = new JDialogSimple();
  }
}

Has any new information come about related to this? Is this now the accepted behavior on the Linux platform?


回答1:


I noticed the one thread that posts an answer has the following :

 super(null, title, Dialog.ModalityType.MODELESS);

I think it should have been the following :

 super(null, title, Dialog.ModalityType.APPLICATION_MODAL);

For my test, changing the above from MODELESS to APPLICATION_MODAL, the Linux JDialog now showed the X to close the window.



来源:https://stackoverflow.com/questions/46428634/jdialog-not-showing-minimize-close-button-on-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!