public void updateAction(boolean ij) { if (toIJ != ij) { final RichTooltip toolTip = new RichTooltip(); toIJ = ij; if (ij) { toolTip.setTitle("Convert to ImageJ"); toolTip.addDescriptionSection("Convert the selected Icy sequence to ImageJ image."); toolTip.addFooterSection("Icy needs to be in detached mode to enabled this feature."); // convert to IJ image button.setText("Convert to IJ"); // button.setIcon(new IcyIcon("icon_icy_ij_2", false)); button.setIcon(new IcyIcon("to_ij", true)); button.setActionRichTooltip(toolTip); button.removeActionListener(toICYAction); button.addActionListener(toIJAction); } else { toolTip.setTitle("Convert to Icy"); toolTip.addDescriptionSection("Convert the selected ImageJ image to Icy sequence."); toolTip.addFooterSection("Icy needs to be in detached mode to enabled this feature."); // convert to ICY sequence button.setText("Convert to Icy"); // button.setIcon(new IcyIcon("icon_ij_icy_2", false)); button.setIcon(new IcyIcon("to_icy", true)); button.setActionRichTooltip(toolTip); button.removeActionListener(toIJAction); button.addActionListener(toICYAction); } } }
public BoundMenuCommandButton( CommandButtonKind kind, String text, String description, ResizableIcon icon, ResizableIcon disabledIcon, Action action) { super(text, icon); this.action = action; setCommandButtonKind(kind); setDisabledIcon(disabledIcon); addActionListener(action); RichTooltip tooltip = new RichTooltip(); tooltip.setTitle(getText()); tooltip.addDescriptionSection( description == null || description.length() == 0 ? " " : description); setActionRichTooltip(tooltip); setPopupRichTooltip(tooltip); PropertyChangeListener l = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("enabled".equals(evt.getPropertyName())) { updateState(); } if (Action.SHORT_DESCRIPTION.equals(evt.getPropertyName())) { updateTooltip(); } } }; action.addPropertyChangeListener(l); updateState(); updateTooltip(); }