【问题标题】:SWT Balloon Tooltip on Iconified Shell图标化外壳上的 SWT 气球工具提示
【发布时间】:2014-09-03 18:15:25
【问题描述】:

我正在使用 openNotifi 方法在托盘图标上创建气球工具提示,但是当外壳图标化时它们也会最小化。即使外壳被图标化,我如何显示通知工具提示?

    public void openNotifi() {      
    final ToolTip tip = new ToolTip(shell, SWT.BALLOON
            | SWT.ICON_INFORMATION);
    tip.setMessage("Here is a message for the user. When the message is too long it wraps. I should say something cool but nothing comes to my mind.");
    Tray tray = shell.getDisplay().getSystemTray();
    if (tray != null) {
        TrayItem item = new TrayItem(tray, SWT.NONE);
        ;
        tip.setText("Notification from a tray item");
        item.setToolTip(tip);
    } else {
        tip.setText("Notification from anywhere");
        tip.setLocation(100, 400);
    }
    tip.setVisible(true);
}

并调用它

    Display.getDefault().syncExec(new Runnable() {
public void run() {
try {
    if (current_username != sender) {
        openNotifi();
    }
}
}
});

【问题讨论】:

    标签: java swt system-tray


    【解决方案1】:

    我创建了一个应用程序窗口(不可见,未打开)并将我的主 shell 作为子窗口打开,并将工具提示创建为不可见应用程序窗口的子窗口。我不知道它是否是真正的解决方案,但它现在有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-15
      • 1970-01-01
      相关资源
      最近更新 更多