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).Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
AUTO_REPEAT |
|
static java.lang.String |
CLIENT_PROPERTY_AUTO_REPEAT |
|
static int |
DEFAULT_DELAY |
|
static int |
DEFAULT_INITIAL_DELAY |
Constructor | Description |
---|---|
AutoRepeatButtonUtils() |
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() |
public static java.lang.String AUTO_REPEAT
public static java.lang.String CLIENT_PROPERTY_AUTO_REPEAT
public static int DEFAULT_DELAY
public static int DEFAULT_INITIAL_DELAY
public static void install(javax.swing.AbstractButton button)
button
- the button.public static void install(javax.swing.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(javax.swing.AbstractButton button)
button
- the button that has auto-repeat feature.protected void installListeners(javax.swing.AbstractButton button, int delay, int initialDelay)
protected void uninstallListeners()
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed
in interface java.awt.event.ActionListener