< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java

Print this page




 330         if (!SunToolkit.isDispatchThreadForAppContext(target)) {
 331             SunToolkit.executeOnEventHandlerThread(target, r);
 332         } else {
 333             r.run();
 334         }
 335     }
 336 
 337     public void displayMessage(String caption, String text, String messageType) {
 338         Point loc = getLocationOnScreen();
 339         Rectangle screen = eframe.getGraphicsConfiguration().getBounds();
 340 
 341         // Check if the tray icon is in the bounds of a screen.
 342         if (!(loc.x < screen.x || loc.x >= screen.x + screen.width ||
 343               loc.y < screen.y || loc.y >= screen.y + screen.height))
 344         {
 345             balloon.display(caption, text, messageType);
 346         }
 347     }
 348 
 349     // It's synchronized with disposal by EDT.

 350     public void showPopupMenu(int x, int y) {
 351         if (isDisposed())
 352             return;
 353 
 354         assert SunToolkit.isDispatchThreadForAppContext(target);
 355 
 356         PopupMenu newPopup = target.getPopupMenu();
 357         if (popup != newPopup) {
 358             if (popup != null) {
 359                 eframe.remove(popup);
 360             }
 361             if (newPopup != null) {
 362                 eframe.add(newPopup);
 363             }
 364             popup = newPopup;
 365         }
 366 
 367         if (popup != null) {
 368             Point loc = ((XBaseWindow)eframe.getPeer()).toLocal(new Point(x, y));
 369             popup.show(eframe, loc.x, loc.y);


 398         } finally {
 399             XToolkit.awtUnlock();
 400         }
 401     }
 402 
 403     // Private method for testing purposes.
 404     private Point getLocationOnScreen() {
 405         return eframe.getLocationOnScreen();
 406     }
 407 
 408     public Rectangle getBounds() {
 409         Point loc = getLocationOnScreen();
 410         return new Rectangle(loc.x, loc.y, loc.x + TRAY_ICON_WIDTH, loc.y + TRAY_ICON_HEIGHT);
 411     }
 412 
 413     void addListeners() {
 414         canvas.addMouseListener(eventProxy);
 415         canvas.addMouseMotionListener(eventProxy);
 416     }
 417 

 418     long getWindow() {
 419         return ((XEmbeddedFramePeer)eframe.getPeer()).getWindow();
 420     }
 421 
 422     public boolean isDisposed() {
 423         return isDisposed;
 424     }
 425 
 426     public String getActionCommand() {
 427         return target.getActionCommand();
 428     }
 429 
 430     static class TrayIconEventProxy implements MouseListener, MouseMotionListener {
 431         XTrayIconPeer xtiPeer;
 432 
 433         TrayIconEventProxy(XTrayIconPeer xtiPeer) {
 434             this.xtiPeer = xtiPeer;
 435         }
 436 
 437         public void handleEvent(MouseEvent e) {




 330         if (!SunToolkit.isDispatchThreadForAppContext(target)) {
 331             SunToolkit.executeOnEventHandlerThread(target, r);
 332         } else {
 333             r.run();
 334         }
 335     }
 336 
 337     public void displayMessage(String caption, String text, String messageType) {
 338         Point loc = getLocationOnScreen();
 339         Rectangle screen = eframe.getGraphicsConfiguration().getBounds();
 340 
 341         // Check if the tray icon is in the bounds of a screen.
 342         if (!(loc.x < screen.x || loc.x >= screen.x + screen.width ||
 343               loc.y < screen.y || loc.y >= screen.y + screen.height))
 344         {
 345             balloon.display(caption, text, messageType);
 346         }
 347     }
 348 
 349     // It's synchronized with disposal by EDT.
 350     @SuppressWarnings("deprecation")
 351     public void showPopupMenu(int x, int y) {
 352         if (isDisposed())
 353             return;
 354 
 355         assert SunToolkit.isDispatchThreadForAppContext(target);
 356 
 357         PopupMenu newPopup = target.getPopupMenu();
 358         if (popup != newPopup) {
 359             if (popup != null) {
 360                 eframe.remove(popup);
 361             }
 362             if (newPopup != null) {
 363                 eframe.add(newPopup);
 364             }
 365             popup = newPopup;
 366         }
 367 
 368         if (popup != null) {
 369             Point loc = ((XBaseWindow)eframe.getPeer()).toLocal(new Point(x, y));
 370             popup.show(eframe, loc.x, loc.y);


 399         } finally {
 400             XToolkit.awtUnlock();
 401         }
 402     }
 403 
 404     // Private method for testing purposes.
 405     private Point getLocationOnScreen() {
 406         return eframe.getLocationOnScreen();
 407     }
 408 
 409     public Rectangle getBounds() {
 410         Point loc = getLocationOnScreen();
 411         return new Rectangle(loc.x, loc.y, loc.x + TRAY_ICON_WIDTH, loc.y + TRAY_ICON_HEIGHT);
 412     }
 413 
 414     void addListeners() {
 415         canvas.addMouseListener(eventProxy);
 416         canvas.addMouseMotionListener(eventProxy);
 417     }
 418 
 419     @SuppressWarnings("deprecation")
 420     long getWindow() {
 421         return ((XEmbeddedFramePeer)eframe.getPeer()).getWindow();
 422     }
 423 
 424     public boolean isDisposed() {
 425         return isDisposed;
 426     }
 427 
 428     public String getActionCommand() {
 429         return target.getActionCommand();
 430     }
 431 
 432     static class TrayIconEventProxy implements MouseListener, MouseMotionListener {
 433         XTrayIconPeer xtiPeer;
 434 
 435         TrayIconEventProxy(XTrayIconPeer xtiPeer) {
 436             this.xtiPeer = xtiPeer;
 437         }
 438 
 439         public void handleEvent(MouseEvent e) {


< prev index next >