swingutil: Set button tooltip text in addModalTooltip

Prior to this commit, addModalTooltip only added a button listener to
update the tooltip when its state changed. This, however, did not set
the initial tooltip and leaves modal tooltip buttons in the client
lacking a tooltip until they are toggled. This commit sets the initial
tooltip state using the same toggle check as is used in the listener.
This commit is contained in:
Tyler Davis
2020-03-31 12:16:47 -07:00
committed by GitHub
parent daca01170b
commit 68e8b0df26

View File

@@ -297,6 +297,7 @@ public class SwingUtil
public static void addModalTooltip(AbstractButton button, String on, String off)
{
button.setToolTipText(button.isSelected() ? on : off);
button.addItemListener(l -> button.setToolTipText(button.isSelected() ? on : off));
}