Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java SWT Messagebox没有';不在上面显示_Java - Fatal编程技术网

Java SWT Messagebox没有';不在上面显示

Java SWT Messagebox没有';不在上面显示,java,Java,我在树莓上运行了我的第一个java应用程序,我在messagebox上遇到了困难。 当我按escape键时,它会显示询问我是否真的想退出,但消息框不会显示在主框架的顶部,而是显示在主框架的背面。如果我按下messagebox按钮,将执行正确的操作。这是我写的代码: private void Mensagem() { Display display = new Display(); Shell shell = new Shell(display); int botoes

我在树莓上运行了我的第一个java应用程序,我在messagebox上遇到了困难。 当我按escape键时,它会显示询问我是否真的想退出,但消息框不会显示在主框架的顶部,而是显示在主框架的背面。如果我按下messagebox按钮,将执行正确的操作。这是我写的代码:

private void Mensagem()
{
    Display display = new Display();
    Shell shell = new Shell(display);


    int botoes = SWT.ICON_QUESTION |SWT.YES | SWT.NO;


    MessageBox mensagem = new MessageBox(shell, botoes);
    mensagem.setMessage("Deseja sair?");                
    int botao = mensagem.open();

    //System.out.println(mensagem.getParent());

    switch (botao) 
    {
        case SWT.YES:
          //System.out.println("SWT.YES");
          Runtime.getRuntime().exit(0);
          break;
        case SWT.NO:
          //System.out.println("SWT.NO");
          break;           
    }
    shell.pack();
    display.dispose();
}   
有人能帮我吗? 提前感谢,,
Joaquim

在构建外壳时,将SWT.APPLICATION\u model添加到标志中:

 new Shell(Display, SWT.APPLICATION_MODAL);
如果失败,可能使用SWT.PRIMARY_model或SWT.SYSTEM_model


编辑:我错了,实际上是SWT。在顶部

感谢您的快速回复。然而,这三个选项都不起作用。我已经解决了这个问题。我没有使用fmcato建议的三个选项,而是使用了“SWT.ON_TOP”,它工作正常!!!我制作了一个可运行的jar文件和一个jar文件,当我运行应用程序时,messageBox不会出现??它似乎正在开发中!!这有什么问题?