src/macosx/classes/sun/lwawt/LWComponentPeer.java

Print this page




 599             // Return a copy to prevent subsequent modifications
 600             return bounds.getBounds();
 601         }
 602     }
 603 
 604     public final Rectangle getSize() {
 605         synchronized (getStateLock()) {
 606             // Return a copy to prevent subsequent modifications
 607             return new Rectangle(bounds.width, bounds.height);
 608         }
 609     }
 610 
 611     @Override
 612     public Point getLocationOnScreen() {
 613         Point windowLocation = getWindowPeer().getLocationOnScreen();
 614         Point locationInWindow = localToWindow(0, 0);
 615         return new Point(windowLocation.x + locationInWindow.x,
 616                 windowLocation.y + locationInWindow.y);
 617     }
 618 











 619     @Override
 620     public void setBackground(final Color c) {
 621         final Color oldBg = getBackground();
 622         if (oldBg == c || (oldBg != null && oldBg.equals(c))) {
 623             return;
 624         }
 625         synchronized (getStateLock()) {
 626             background = c;
 627         }
 628         final D delegate = getDelegate();
 629         if (delegate != null) {
 630             synchronized (getDelegateLock()) {
 631                 // delegate will repaint the target
 632                 delegate.setBackground(c);
 633             }
 634         } else {
 635             repaintPeer();
 636         }
 637     }
 638 




 599             // Return a copy to prevent subsequent modifications
 600             return bounds.getBounds();
 601         }
 602     }
 603 
 604     public final Rectangle getSize() {
 605         synchronized (getStateLock()) {
 606             // Return a copy to prevent subsequent modifications
 607             return new Rectangle(bounds.width, bounds.height);
 608         }
 609     }
 610 
 611     @Override
 612     public Point getLocationOnScreen() {
 613         Point windowLocation = getWindowPeer().getLocationOnScreen();
 614         Point locationInWindow = localToWindow(0, 0);
 615         return new Point(windowLocation.x + locationInWindow.x,
 616                 windowLocation.y + locationInWindow.y);
 617     }
 618 
 619     /**
 620      * Returns the cursor of the peer, which is cursor of the target by default,
 621      * but peer can override this behavior.
 622      *
 623      * @param p Point relative to the peer.
 624      * @return Cursor of the peer or null if default cursor should be used.
 625      */
 626     protected Cursor getCursor(final Point p) {
 627         return getTarget().getCursor();
 628     }
 629 
 630     @Override
 631     public void setBackground(final Color c) {
 632         final Color oldBg = getBackground();
 633         if (oldBg == c || (oldBg != null && oldBg.equals(c))) {
 634             return;
 635         }
 636         synchronized (getStateLock()) {
 637             background = c;
 638         }
 639         final D delegate = getDelegate();
 640         if (delegate != null) {
 641             synchronized (getDelegateLock()) {
 642                 // delegate will repaint the target
 643                 delegate.setBackground(c);
 644             }
 645         } else {
 646             repaintPeer();
 647         }
 648     }
 649