From: Niki Roo Date: Fri, 1 May 2020 14:06:34 +0000 (+0200) Subject: ListModel sync tooltips X-Git-Tag: fanfix-swing-1.1.0~21 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=b92e1283ebc0d70da9fbcd5a3100dd36803d2cb5;p=fanfix-swing.git ListModel sync tooltips --- diff --git a/src/be/nikiroo/utils/ui/ListModel.java b/src/be/nikiroo/utils/ui/ListModel.java index 7103dbac..137897ae 100644 --- a/src/be/nikiroo/utils/ui/ListModel.java +++ b/src/be/nikiroo/utils/ui/ListModel.java @@ -276,10 +276,11 @@ public class ListModel extends DefaultListModel6 { fireElementChanged(oldIndex); fireElementChanged(index); - Window oldTooltip = tooltip; - tooltip = null; - if (oldTooltip != null) { - oldTooltip.setVisible(false); + synchronized (tooltipWatcher) { + if (tooltip != null) { + tooltip.setVisible(false); + } + tooltip = null; } if (ListModel.this.tooltipCreator != null) { @@ -293,6 +294,13 @@ public class ListModel extends DefaultListModel6 { @Override protected void done() { + synchronized (tooltipWatcher) { + if (tooltip != null) { + tooltip.setVisible(false); + } + tooltip = null; + } + if (index < 0 || index != hoveredIndex) { return; @@ -303,7 +311,12 @@ public class ListModel extends DefaultListModel6 { return; } - tooltip = newTooltip(index, me); + synchronized (tooltipWatcher) { + if (tooltip != null) { + tooltip.setVisible(false); + } + tooltip = newTooltip(index, me); + } } }); } @@ -575,16 +588,19 @@ public class ListModel extends DefaultListModel6 { newTooltip.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - Window promotedTooltip = tooltipCreator .generateTooltip(value, false); - promotedTooltip.setLocation(newTooltip.getLocation()); + if (promotedTooltip != null) { + promotedTooltip.setLocation(me.getXOnScreen(), + me.getYOnScreen()); + promotedTooltip.setVisible(true); + } + newTooltip.setVisible(false); - promotedTooltip.setVisible(true); } }); - newTooltip.setLocation(me.getXOnScreen(), me.getYOnScreen()); + newTooltip.setLocation(me.getXOnScreen(), me.getYOnScreen()); newTooltip.setVisible(true); }