Java在Ubuntu上的托盘消息外观 [英] Java Look-And-Feel for Tray Messages on Ubuntu

查看:66
本文介绍了Java在Ubuntu上的托盘消息外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过trayIcon.displayMessage(...)在系统托盘上显示消息,但它们看起来不太好. 我试图将其外观更改为系统标准,但是在创建图标之前调用UIManager.setLookAndFeel(...)并没有任何改变.

I'm displaying messages on the system tray via trayIcon.displayMessage(...) but they don't look nice. I tried to change their look and feel to the system standard, but calling UIManager.setLookAndFeel(...) before creating the icon didn't change anything.

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

tray = SystemTray.getSystemTray();
popup = new PopupMenu();
trayIcon = new TrayIcon(image, "Tray Demo", popup);
tray.add(trayIcon);

trayIcon.displayMessage("Tray Test", "Tray demo started", TrayIcon.MessageType.INFO);

推荐答案

Here you can find a great tutorial how to get rid of awt and use swing. Then you can have every look and feel you want.

唯一的问题是,如果在弹出菜单之外单击,弹出菜单不会消失.最快的解决方法是添加一个菜单项(名为Dispose或您想要的任何名称),该菜单项什么也不做,但是您可以单击它,菜单消失:)

The only problem is that the popup menu does not disappear if you click outside of it. The quickest workaround can be adding a menu item (named Dispose or whatever you want) which does nothing but you can click on it and the menu disappears :)

这篇关于Java在Ubuntu上的托盘消息外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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