public class AutoRepeatButtonUtils extends Object implements ActionListener, 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).Modifier and Type | Field and Description |
---|---|
static String |
AUTO_REPEAT |
static String |
CLIENT_PROPERTY_AUTO_REPEAT |
static int |
DEFAULT_DELAY |
static int |
DEFAULT_INITIAL_DELAY |
Constructor and Description |
---|
AutoRepeatButtonUtils() |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent event) |
static void |
install(AbstractButton button)
Enable auto-repeat feature on the button.
|
static void |
install(AbstractButton button,
int delay,
int initialDelay)
Enable auto-repeat feature on the button.
|
protected void |
installListeners(AbstractButton button,
int delay,
int initialDelay) |
void |
mouseClicked(MouseEvent e) |
void |
mouseEntered(MouseEvent e) |
void |
mouseExited(MouseEvent e) |
void |
mousePressed(MouseEvent e) |
void |
mouseReleased(MouseEvent e) |
static void |
uninstall(AbstractButton button)
Disabled the auto-repeat feature on the button which called install before.
|
protected void |
uninstallListeners() |
public static String AUTO_REPEAT
public static String CLIENT_PROPERTY_AUTO_REPEAT
public static int DEFAULT_DELAY
public static int DEFAULT_INITIAL_DELAY
public static void install(AbstractButton button)
button
- the button.public static void install(AbstractButton button, int delay, int initialDelay)
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.public static void uninstall(AbstractButton button)
button
- the button that has auto-repeat feature.protected void installListeners(AbstractButton button, int delay, int initialDelay)
protected void uninstallListeners()
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
public void actionPerformed(ActionEvent event)
actionPerformed
in interface ActionListener