Changeset 13475 in josm for trunk/src


Ignore:
Timestamp:
2018-02-28T20:10:44+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #16030 - call getMousePosition() only when needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ButtonMarker.java

    r12846 r13475  
    5252        buttonRectangle.setLocation(screen.x+4, screen.y+2);
    5353        paintIcon(mv, g, screen.x+4, screen.y+2);
    54         Border b;
    55         Point mousePosition = mv.getMousePosition();
    56 
    57         // mouse is inside the window
    58         if (mousePosition != null && mousePressed && containsPoint(mousePosition)) {
    59             b = BorderFactory.createBevelBorder(BevelBorder.LOWERED);
    60         } else {
    61             b = BorderFactory.createBevelBorder(BevelBorder.RAISED);
     54        boolean lowered = false;
     55        if (mousePressed) {
     56            Point mousePosition = mv.getMousePosition(); // slow and can throw NPE, see JDK-6840067
     57            // mouse is inside the window
     58            lowered = mousePosition != null && containsPoint(mousePosition);
    6259        }
     60        Border b = BorderFactory.createBevelBorder(lowered ? BevelBorder.LOWERED : BevelBorder.RAISED);
    6361        Insets inset = b.getBorderInsets(mv);
    6462        Rectangle r = new Rectangle(buttonRectangle);
Note: See TracChangeset for help on using the changeset viewer.