Browse Source

Fixed string VARIANT_* properties not being applied to tooltip style.

pull/97/head
weisj 5 years ago
parent
commit
d42310f04f
  1. 18
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java

18
core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java

@ -52,6 +52,7 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe
public static final String KEY_PLAIN_TOOLTIP = "JComponent.plainTooltip"; public static final String KEY_PLAIN_TOOLTIP = "JComponent.plainTooltip";
public static final String VARIANT_PLAIN = "plain"; public static final String VARIANT_PLAIN = "plain";
public static final String VARIANT_BALLOON = "balloon"; public static final String VARIANT_BALLOON = "balloon";
public static final String VARIANT_PLAIN_BALLOON = "plainBalloon";
public static final String TIP_TEXT_PROPERTY = "tiptext"; public static final String TIP_TEXT_PROPERTY = "tiptext";
public static final String KEY_PAINT_ALPHA = KEY_PREFIX + "paintAlpha"; public static final String KEY_PAINT_ALPHA = KEY_PREFIX + "paintAlpha";
public static final String KEY_CONTEXT = KEY_PREFIX + "toolTipContext"; public static final String KEY_CONTEXT = KEY_PREFIX + "toolTipContext";
@ -340,14 +341,23 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe
private void updateStyle() { private void updateStyle() {
JComponent comp = toolTip.getComponent(); JComponent comp = toolTip.getComponent();
if (comp != null) { if (comp != null) {
Object style = comp.getClientProperty(KEY_STYLE); ToolTipStyle style = getStyle(comp.getClientProperty(KEY_STYLE));
Object tooltipStyle = toolTip.getClientProperty(KEY_STYLE); ToolTipStyle tooltipStyle = getStyle(toolTip.getClientProperty(KEY_STYLE));
toolTip.putClientProperty(KEY_STYLE, style instanceof ToolTipStyle ? style : toolTip.putClientProperty(KEY_STYLE, style != null ? style :
tooltipStyle instanceof ToolTipStyle ? tooltipStyle tooltipStyle != null ? tooltipStyle
: ToolTipStyle.PLAIN_BALLOON); : ToolTipStyle.PLAIN_BALLOON);
} }
} }
private ToolTipStyle getStyle(final Object style) {
if (style instanceof ToolTipStyle) return (ToolTipStyle) style;
String name = style.toString();
if (VARIANT_PLAIN_BALLOON.equals(name)) return ToolTipStyle.PLAIN_BALLOON;
if (VARIANT_BALLOON.equals(name)) return ToolTipStyle.BALLOON;
if (VARIANT_PLAIN.equals(name)) return ToolTipStyle.PLAIN;
return null;
}
protected void updateSize() { protected void updateSize() {
toolTip.setTipText(toolTip.getTipText()); toolTip.setTipText(toolTip.getTipText());
toolTip.setPreferredSize(getPreferredSize(toolTip)); toolTip.setPreferredSize(getPreferredSize(toolTip));

Loading…
Cancel
Save