提交 bb424638 authored 作者: Thomas Mueller's avatar Thomas Mueller

Better system tray icon for Mac OS X

上级 2cb5a2a5
...@@ -55,7 +55,7 @@ ShutdownHandler { ...@@ -55,7 +55,7 @@ ShutdownHandler {
//## AWT begin ## //## AWT begin ##
Frame frame; Frame frame;
private Font font; private Font font;
private Image icon16, icon24; private Image icon16, icon22, icon24;
private Button startBrowser; private Button startBrowser;
//## AWT end ## //## AWT end ##
private Server web, tcp, pg; private Server web, tcp, pg;
...@@ -181,7 +181,8 @@ ShutdownHandler { ...@@ -181,7 +181,8 @@ ShutdownHandler {
} }
try { try {
icon16 = loadImage("/org/h2/res/h2.png"); icon16 = loadImage("/org/h2/res/h2.png");
icon24 = loadImage("/org/h2/res/h2b.png"); icon22 = loadImage("/org/h2/res/h2-22.png");
icon24 = loadImage("/org/h2/res/h2-24.png");
if (!createTrayIcon()) { if (!createTrayIcon()) {
showWindow(true); showWindow(true);
} }
...@@ -289,9 +290,14 @@ ShutdownHandler { ...@@ -289,9 +290,14 @@ ShutdownHandler {
Dimension d = (Dimension) Class.forName("java.awt.SystemTray"). Dimension d = (Dimension) Class.forName("java.awt.SystemTray").
getMethod("getTrayIconSize"). getMethod("getTrayIconSize").
invoke(tray); invoke(tray);
Image icon;
Image icon = (d.width >= 24 && d.height >= 24) ? icon24 : icon16; if (d.width >= 24 && d.height >= 24) {
icon = icon24;
} else if (d.width >= 22 && d.height >= 22) {
icon = icon22;
} else {
icon = icon16;
}
// TrayIcon icon = new TrayIcon(image, "H2 Database Engine", menuConsole); // TrayIcon icon = new TrayIcon(image, "H2 Database Engine", menuConsole);
Object trayIcon = Class.forName("java.awt.TrayIcon"). Object trayIcon = Class.forName("java.awt.TrayIcon").
getConstructor(Image.class, String.class, PopupMenu.class). getConstructor(Image.class, String.class, PopupMenu.class).
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论