/** * Open the window. */ public void open() { try { Display display = Display.getDefault(); this.createContents(); this.shell.open(); this.shell.layout(); while (!this.shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } finally { Tray tray = Display.getDefault().getSystemTray(); if (tray != null) { for (TrayItem item : tray.getItems()) { item.dispose(); } } } }
private void addTrayItem() { Display display; Tray tray; Shell shell; display = Main.getDisplay(); tray = display.getSystemTray(); shell = Main.getShell(); if (tray != null) { trayItem = new TrayItem(tray, SWT.NONE); trayItem.setToolTipText("Dazzl"); //$NON-NLS-1$ trayItem.setImage(admIcon); //$NON-NLS-1$ trayItem.addListener(SWT.MenuDetect, new Listener() { public void handleEvent(Event event) { if (menu != null) { menu.setVisible(true); } } }); } else { CommonDialogs.showError(Messages .getString("SystemTray.error.no_system_tray"), null); } }
public TrayIcon(Display display, MainWindow window) { if(display == null) { throw new NullPointerException("Display cannot be null."); } if(window == null) { throw new NullPointerException("Main window cannot be null."); } m_mainDisplay = display; m_mainWindow = window; // Create tray item Tray tray = display.getSystemTray(); m_item = new TrayItem(tray, SWT.NONE); m_item.setText("Droid Navi"); // Set Image m_logo = AppLogo.getLogo(AppLogo.LogoType.TRAY_ICON, display); m_item.setImage(m_logo); init(m_item); }
/** * トレイアイコンを追加します * * @param display * @return */ private TrayItem addTrayItem(final Display display) { // トレイアイコンを追加します Tray tray = display.getSystemTray(); TrayItem item = new TrayItem(tray, SWT.NONE); Image image = display.getSystemImage(SWT.ICON_INFORMATION); item.setImage(image); item.setToolTipText(AppConstants.NAME + AppConstants.VERSION); item.addListener(SWT.Selection, new TraySelectionListener(this.shell)); item.addMenuDetectListener(new TrayItemMenuListener(this.getShell())); return item; }
/** * トレイアイコンを追加します * * @param display * @return */ private TrayItem addTrayItem(final Display display) { // トレイアイコンを追加します Tray tray = display.getSystemTray(); TrayItem item = new TrayItem(tray, SWT.NONE); Image image = display.getSystemImage(SWT.ICON_INFORMATION); item.setImage(image); item.setToolTipText(AppConstants.NAME + " " + AppConstants.VERSION); item.addListener(SWT.Selection, new TraySelectionListener(this.shell)); item.addMenuDetectListener(new TrayItemMenuListener(this.getShell())); return item; }
/** * 窗口是可见状态时,则隐藏窗口,同时把系统栏中图标删除 窗口是隐藏状态时,则显示窗口,并且在系统栏中显示图标 * * @param shell * 窗口 * @param tray * 系统栏图标控件 */ private void toggleDisplay(Shell shell, Tray tray) { try { shell.setVisible(!shell.isVisible()); if (shell.getVisible()) { shell.setMinimized(false); shell.setActive(); } } catch (Exception e) { e.printStackTrace(); } }
private TrayItem initTaskItem(Shell shell) { final Tray tray = shell.getDisplay().getSystemTray(); TrayItem trayItem = new TrayItem(tray, SWT.NONE); trayImage = AbstractUIPlugin.imageDescriptorFromPlugin( "com.dmagik.sheetrackimporter", "/icons/alt_window_16.gif") .createImage(); trayItem.setImage(trayImage); trayItem.setToolTipText("Double-click to maximize SheetRack Importer"); return trayItem; }
public Tray getSWT() { return tray; }
public Tray getTray() { return tray; }