1 20 21 26 package org.jdesktop.jdic.tray.internal.impl; 27 28 import org.jdesktop.jdic.tray.internal.SystemTrayService; 29 import org.jdesktop.jdic.tray.internal.TrayIconService; 30 import org.jdesktop.jdic.tray.TrayIcon; 31 import java.awt.Toolkit ; 32 33 34 public class WinSystemTrayService implements SystemTrayService { 35 36 public WinSystemTrayService() {} 37 38 public void addNotify() {} 39 40 public void addTrayIcon(TrayIcon ti, TrayIconService tis, int trayIndex) { 41 WinTrayIconService trayIcon = (WinTrayIconService) tis; 42 trayIcon.addNotify(); 43 } 44 45 public void removeTrayIcon(TrayIcon ti, TrayIconService tis, int trayIndex) { 46 WinTrayIconService trayIcon = (WinTrayIconService) tis; 47 trayIcon.remove(); 48 } 49 50 static Thread display_thread; 51 52 static { 53 Toolkit t = Toolkit.getDefaultToolkit(); 57 t.sync(); 58 59 display_thread = new DisplayThread(); 60 display_thread.setDaemon(true); 61 synchronized(DisplayThread.class){ 62 try{ 63 display_thread.start(); 64 DisplayThread.class.wait(); 65 }catch(InterruptedException e){ 66 } 68 } 69 } 70 } 71 72 class DisplayThread extends Thread { 73 private static native void initTray(); 74 private static native void eventLoop(); 75 static { 76 System.loadLibrary("tray"); 77 } 78 public void run(){ 79 synchronized(DisplayThread.class){ 80 DisplayThread.initTray(); 81 DisplayThread.class.notify(); 82 } 83 DisplayThread.eventLoop(); 84 } 85 } | Popular Tags |