package com.sbmckg.swt; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Tray; import org.eclipse.swt.widgets.TrayItem; /** * 系统托盘图标测试 * @author root * */ public class TestTray { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Display display = Display.getDefault(); Shell shell = new Shell(display); Image image = new Image(display.getDefault(),"36.jpg"); Tray tray = display.getSystemTray(); TrayItem item = new TrayItem(tray,SWT.NONE); item.setImage(image); item.setToolTipText("Tray Test"); shell.open(); while(!shell.isDisposed()){ if(!display.readAndDispatch()){ display.sleep(); } } item.dispose(); display.dispose(); } } |