JDialog在Linux上未显示最小化/关闭按钮 [英] JDialog not showing minimize/close button on Linux

查看:105
本文介绍了JDialog在Linux上未显示最小化/关闭按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题以前曾被问过,但根据我的发现,这些问题和答案来自几年前,希望有更新/新的信息.

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.

相同的代码在Windows上也可以正常运行,因为它在右上角显示了X. 在Linux上,右上角没有显示任何内容. Windows正在使用JDK 1.8.0_60 Linux正在使用1.8.0_111-b15

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

基于研究,已知此问题存在于各种口味的Linux中.

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();
  }
}

是否有与此相关的新信息? 现在是Linux平台上可接受的行为吗?

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

推荐答案

我注意到发布答案的一个线程具有以下内容:

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);

对于我的测试,将以上内容从MODELESS更改为APPLICATION_MODAL,Linux JDialog现在显示X来关闭窗口.

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

这篇关于JDialog在Linux上未显示最小化/关闭按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆