没有任何按钮且没有模态的swt rcp消息对话框

swt rcp message dialog without any button and no modal

我需要你的帮助,在我的 swt 应用程序中,我需要在加载一些 jfreechart 图表时显示一条简单的消息。我只是在图表生成方法的开头放置了一个 shell,并在该方法的末尾关闭了 shell。我知道这不是最好的解决方案,但我需要一种简单的方法来做到这一点。问题是 shell 是模态的,它之前关闭了一些其他作业 运行,所以我需要一个 NO MODAL 弹出窗口。我尝试使用消息框和对话框,但它们都有按钮,我只需要一个没有任何按钮的弹出窗口,只有一个标签和一个图像。 谢谢!

我把相关代码放上去:

在生成图表的方法中我调用了shell创建方法:

    Display display = PlatformUI.createDisplay();
    Shell shell = new Shell(display,SWT.BACKGROUND);
    generateMessageDialog(display,shell);

这是创建 shell:

的方法
    Monitor primary = display.getPrimaryMonitor ();
    Rectangle bounds = primary.getBounds ();
    shell.setSize(455, 295);
    Rectangle rect = shell.getBounds ();
    int x = bounds.x + (bounds.width - rect.width) / 2;
    int y = bounds.y + (bounds.height - rect.height) / 2;
    shell.setLocation (x, y);
    shell.setLayout(new FormLayout());
    shell.setText("Information");
    Label label = new Label(shell, SWT.NONE);
    ImageDescriptor id =      Activator.getImageDescriptor("icons/loading4_modificado.gif");
    Image image = id.createImage();
    label.setImage(image);

    Label label2=new Label(shell, SWT.NONE);
    label2.setText("Generating chart. Please, wait...");

    FormData label1FD = new FormData();
    label1FD.top = new FormAttachment(0, 120);
    label1FD.left = new FormAttachment(0, 90);
    label.setLayoutData(label1FD);

    FormData label2FD = new FormData();
    label2FD.top = new FormAttachment(0, 130);
    label2FD.left = new FormAttachment(0, 160);
    label2.setLayoutData(label2FD);
    label2.setFont(new org.eclipse.swt.graphics.Font(null,"Arial", Font.PLAIN, 10));

    shell.open();
    shell.layout();

创建 Shell 样式如下:

new Shell(parentShell, SWT.ON_TOP | SWT.TOOL | SWT.NO_FOCUS);

给你 'tool tip' 风格 shell。

这听起来像是您要的东西有点像闪屏。

您可能想要的键样式是 SWT.ON_TOP,它将 window 置于顶部。

作为 SWT Snippets here: Snippet104

的一部分,有一个完整的启动画面示例