Class AutoRepeatButtonUtils

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.MouseListener, java.util.EventListener

    public class AutoRepeatButtonUtils
    extends java.lang.Object
    implements java.awt.event.ActionListener, java.awt.event.MouseListener
    AutoRepeatButtonUtils is a utility class which can make a button automatically trigger action events continuously. To enable this feature on any button, just call AutoRepeatButtonUtils.install(button) or AutoRepeatButtonUtils.install(button, delay, initialDelay).
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent event)  
      static void install​(javax.swing.AbstractButton button)
      Enable auto-repeat feature on the button.
      static void install​(javax.swing.AbstractButton button, int delay, int initialDelay)
      Enable auto-repeat feature on the button.
      protected void installListeners​(javax.swing.AbstractButton button, int delay, int initialDelay)  
      void mouseClicked​(java.awt.event.MouseEvent e)  
      void mouseEntered​(java.awt.event.MouseEvent e)  
      void mouseExited​(java.awt.event.MouseEvent e)  
      void mousePressed​(java.awt.event.MouseEvent e)  
      void mouseReleased​(java.awt.event.MouseEvent e)  
      static void uninstall​(javax.swing.AbstractButton button)
      Disabled the auto-repeat feature on the button which called install before.
      protected void uninstallListeners()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • AUTO_REPEAT

        public static java.lang.String AUTO_REPEAT
      • CLIENT_PROPERTY_AUTO_REPEAT

        public static java.lang.String CLIENT_PROPERTY_AUTO_REPEAT
      • DEFAULT_DELAY

        public static int DEFAULT_DELAY
      • DEFAULT_INITIAL_DELAY

        public static int DEFAULT_INITIAL_DELAY
    • Constructor Detail

      • AutoRepeatButtonUtils

        public AutoRepeatButtonUtils()
    • Method Detail

      • install

        public static void install​(javax.swing.AbstractButton button)
        Enable auto-repeat feature on the button.
        Parameters:
        button - the button.
      • install

        public static void install​(javax.swing.AbstractButton button,
                                   int delay,
                                   int initialDelay)
        Enable auto-repeat feature on the button.
        Parameters:
        button - the button.
        delay - the delay between action events, in ms.
        initialDelay - the initial delay, in ms. It is from the time mouse is pressed to the first action event.
      • uninstall

        public static void uninstall​(javax.swing.AbstractButton button)
        Disabled the auto-repeat feature on the button which called install before.
        Parameters:
        button - the button that has auto-repeat feature.
      • installListeners

        protected void installListeners​(javax.swing.AbstractButton button,
                                        int delay,
                                        int initialDelay)
      • uninstallListeners

        protected void uninstallListeners()
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent e)
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent e)
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent e)
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
      • mouseClicked

        public void mouseClicked​(java.awt.event.MouseEvent e)
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent e)
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent event)
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener