/** * Get tray icon image from the desktopgui resources in the jar file. * @return image used for the tray icon * @throws AWTException if image not found */ private Image getTrayImage() throws AWTException { String img; if (SystemVersion.isWindows()) img = WIN_ICON; else if (SystemVersion.isMac()) img = MAC_ICON; else img = LIN_ICON; URL url = getClass().getResource(PNG_DIR + img); if (url == null) throw new AWTException("cannot load tray image " + img); Image image = Toolkit.getDefaultToolkit().getImage(url); return image; }
@Override public void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException { // TODO: Implement this correctly. throw new AWTException("Not yet supported."); }
/** * Add the tray icon to the system tray and start everything up. */ public synchronized void startManager() throws AWTException { if (!SystemTray.isSupported()) throw new AWTException("SystemTray not supported"); tray = SystemTray.getSystemTray(); // Windows typically has tooltips; Linux (at least Ubuntu) doesn't String tooltip = SystemVersion.isWindows() ? _t("I2P: Right-click for menu") : null; TrayIcon ti; if (_useSwing) ti = getSwingTrayIcon(tooltip); else ti = getAWTTrayIcon(tooltip); ti.setImageAutoSize(true); //Resize image to fit the system tray tray.add(ti); trayIcon = ti; }
protected void loadImage() throws AWTException { Image theImage = null; InputStream imageInputStream = getClass().getResourceAsStream(resourceName); if (imageInputStream == null) { // The image resource was not found loadFailed = true; throw new AWTException("Image resource " + resourceName + " not found."); } ByteArrayOutputStream imageBytes = new ByteArrayOutputStream(); int arraySize = 1024; byte[] imageArray = new byte[arraySize]; int readCode; try { while ((readCode = imageInputStream.read(imageArray, 0, arraySize)) > -1) { imageBytes.write(imageArray, 0, readCode); } imageBytes.close(); imageArray = imageBytes.toByteArray(); imageInputStream.close(); theImage = Toolkit.getDefaultToolkit().createImage(imageArray); } catch (IOException ioException) { System.out.println("Error reading image data"); ioException.printStackTrace(); } setImage(theImage); if (loadLater) return; waitForImage(); }
public static boolean isShiftDown(Component c) throws AWTException { final List<Boolean> res = new ArrayList<Boolean>(); final KeyListener listener = new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { res.add(e.isShiftDown()); } }; c.addKeyListener(listener); new Robot().keyRelease(KeyEvent.VK_ALT); try {Thread.sleep(50);} catch (InterruptedException e) {} c.removeKeyListener(listener); if (res.size() > 0) return res.get(0); throw new AWTException("Could not get shift key status."); }
throw new AWTException("Too many colors.");
throw new AWTException( "System tray not supported." );
throw new AWTException("Grabber returned false: " + grabber.status());
throw new AWTException ("headless environment");