diff --git a/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java b/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java index c9e84841d014..45249bce004e 100644 --- a/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java +++ b/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java @@ -177,7 +177,10 @@ public class LinkLabel extends JLabel { @NotNull protected Rectangle getTextBounds() { - return UIUtil.getLabelTextBounds(this); + if (textR.isEmpty()) { + updateLayoutRectangles(); + } + return textR; } protected Color getTextColor() { @@ -211,6 +214,17 @@ public class LinkLabel extends JLabel { private final JBRectangle viewR = new JBRectangle(); protected boolean isInClickableArea(Point pt) { + updateLayoutRectangles(); + if (getIcon() != null) { + iconR.width += getIconTextGap(); //todo[kb] icon at right? + if (iconR.contains(pt)) { + return true; + } + } + return textR.contains(pt); + } + + private void updateLayoutRectangles() { iconR.clear(); textR.clear(); final Insets insets = getInsets(null); @@ -230,13 +244,6 @@ public class LinkLabel extends JLabel { iconR, textR, getIconTextGap()); - if (getIcon() != null) { - iconR.width += getIconTextGap(); //todo[kb] icon at right? - if (iconR.contains(pt)) { - return true; - } - } - return textR.contains(pt); } //for GUI tests