Class NMPopupButton

All Implemented Interfaces:
com.nomagic.awt.HelpInformationProvider, KeyListener, MouseListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, SwingConstants
Direct Known Subclasses:
NMActionButton

@OpenApi public class NMPopupButton extends JButton implements MouseListener, Serializable, KeyListener, com.nomagic.awt.HelpInformationProvider
This is simple image popup button bean. Then user moves mouse on it, button border is drawn as raised 3D rectangle; if button is pushed, it's border is drawn as hollow 3D rectangle. Button size is the same as image size. This button has three modes: pushed - is button pushed toggle - is button a toggle button. If button is not a toggle button, the user can only push it (not to release) sticky - is button is a sticky button. If button is not sticky, after mouse released it will lose it's pushed state. The button can registry ActionListeners. ActionEvent is fired when user presses and releases mouse on the button. If mouse was only pressed on the button and releases elsewhere, ActionEvent is not fired. The button also can registry HelpListeners. HelpEvent is fired when user moves mouse pointer on the button or moves it out. When mouse moves in HelpEvent is fired with parameter getTooltipText(), when mouse moves out, HelpEvent is fired with parameter null.
See Also:
  • Constructor Details

    • NMPopupButton

      @OpenApi public NMPopupButton()
      Constructs not pushed button with no image, empty command string and empty help string. The size of the button will be zero.
    • NMPopupButton

      @OpenApi public NMPopupButton(Action action)
      Creates button from given action.
      See Also:
    • NMPopupButton

      @OpenApi public NMPopupButton(Icon icon)
      Creates button with given icon.
      Parameters:
      icon - icon for button.
      See Also:
  • Method Details

    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Processes the mouse release event. At first this method checks if the button has focus (mFocus is true). If this is true, ActionEvent will be thrown.
      Specified by:
      mouseReleased in interface MouseListener
      Parameters:
      e - the release mouse event;
    • rightClickAction

      public void rightClickAction(MouseEvent e)
      This method is called if right click is done on the button.
      Parameters:
      e - click event.
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
      See Also:
    • mousePressed

      public void mousePressed(MouseEvent e)
      Processes the mouse pressed action. After press button must be drawn as pushed.
      Specified by:
      mousePressed in interface MouseListener
      Parameters:
      e - MouseEvent
      See Also:
      • #setPushed
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Processes the mouse enter action. This method sets focus flag, and notifies HelpListeners with parameter "help string".
      Specified by:
      mouseEntered in interface MouseListener
      Parameters:
      e - MouseEvent
    • mouseExited

      public void mouseExited(MouseEvent e)
      Processes the mouse exit action. Calls notifyHelpListeners method with null as parameter.
      Specified by:
      mouseExited in interface MouseListener
      Parameters:
      e - MouseEvent
      See Also:
    • addHelpListener

      public void addHelpListener(com.nomagic.awt.HelpListener l)
      Informs the component that this HelpListener is interested in the help events generated by this component.
      Specified by:
      addHelpListener in interface com.nomagic.awt.HelpInformationProvider
      Parameters:
      l - the HelpListener
      See Also:
    • removeHelpListener

      public void removeHelpListener(com.nomagic.awt.HelpListener l)
      Informs the component that this HelpListener is no longer interested in the help events generated by this component.
      Specified by:
      removeHelpListener in interface com.nomagic.awt.HelpInformationProvider
      Parameters:
      l - the HelpListener
      See Also:
    • notifyHelpListeners

      public void notifyHelpListeners(String newHelp)
      Processes the mouse enter and mouse exit events. This method calls the helpChanged() methods of all the listeners who have expressed their interest by calling addHelpListener
      Parameters:
      newHelp - the new help string for HelpEvent
    • setShortcuts

      public void setShortcuts(List scut)
      Sets shortcut for popup button.
    • getShortcuts

      public List getShortcuts()
      Gets list of shortcut for button activation
      Returns:
      list of shortcuts.
    • keyPressed

      public void keyPressed(KeyEvent evt)
      Specified by:
      keyPressed in interface KeyListener
    • keyReleased

      public void keyReleased(KeyEvent evt)
      Specified by:
      keyReleased in interface KeyListener
    • keyTyped

      public void keyTyped(KeyEvent evt)
      Specified by:
      keyTyped in interface KeyListener
    • updateUI

      public void updateUI()
      Resets the UI property to a value from the current look and feel.
      Overrides:
      updateUI in class JButton
      See Also:
    • getUIClassID

      public String getUIClassID()
      Returns a string that specifies the name of the l&f class that renders this component.
      Overrides:
      getUIClassID in class JButton
      Returns:
      String "ToggleButtonUI"
      See Also:
    • setToolTipText

      public void setToolTipText(String text)
      Registers the text to display in a tool tip. The text displays when the cursor lingers over the component.

      See How to Use Tool Tips in The Java Tutorial for further documentation.

      Overrides:
      setToolTipText in class JComponent
      Parameters:
      text - the string to display; if the text is null, the tool tip is turned off for this component
      See Also: