button.addActionListener(getDisplayHelpFromSource()); } else if (comp instanceof Button) { Button button = (Button) comp; button.addActionListener(getDisplayHelpFromSource());
/** * Enables help for a MenuItem. This method sets a * Component's helpID and HelpSet and adds an ActionListener. * When an action is performed * it displays the Component's helpID and HelpSet in the default viewer. * * @param comp the MenuItem to set the id and hs on. If comp is null * an IllegalAgrumentException is thrown. * @param id the String value of an Map.ID. * @param hs the HelpSet the id is in. If hs is null the default HelpSet * will be assumed. * @see CSH.setHelpID * @see CSH.setHelpSet * @see java.awt.MenuItem * @throws IllegalArgumentException if comp is null. */ public void enableHelpOnButton(MenuItem comp, String id, HelpSet hs) { if (comp == null) { throw new IllegalArgumentException("Invalid Component"); } if (id == null) { throw new NullPointerException("id"); } CSH.setHelpIDString(comp, id); if (hs != null) { CSH.setHelpSet(comp, hs); } comp.addActionListener(getDisplayHelpFromSource()); }
if (obj instanceof AbstractButton) { AbstractButton button = (AbstractButton) obj; button.addActionListener(getDisplayHelpFromSource()); } else if (obj instanceof Button) { Button button = (Button) obj; button.addActionListener(getDisplayHelpFromSource()); } else if (obj instanceof MenuItem) { MenuItem item = (MenuItem) obj; item.addActionListener(getDisplayHelpFromSource());