be.ugent.caagt.swirl.commands

Class RepeaterCommand


public abstract class RepeaterCommand
extends ActionCommand

Extension of ActionCommand which creates 'repeater buttons'. Buttons of this type execute some action repeatedly while the button is being held down.

The action to be repeated is specified in handleRepeat(). When the button is first pressed handleFirst() is called, before handleRepeat. Finally, if the button is released within the button boundaries RepeaterCommand is called, as with ActionCommand, and if the mouse button is released outside the button boundaries, handleCancel() is invoked.

Only has any effect on buttons of type JButton, not on toggle buttons or menu items.

Important note: work on this part of the Swirl library will be discontinued because unfortunately newer versions of the GUI commands framework will no longer be available as open source. In due course this class will become deprecated and will eventually be removed from the library.

Constructor Summary

RepeaterCommand()
RepeaterCommand(CommandManager commandManager, String commandId)
RepeaterCommand(String commandId)

Method Summary

void
attach(AbstractButton button, String faceName)
void
detach(AbstractButton button)
abstract void
handleCancel()
Method to be executed when the button press is cancelled.
abstract void
handleFirst()
Method to be executed when the button is first pressed.
abstract void
handleRepeat()
Method to be executed repeatedly while the button is pressed.
void
setInterval(int interval)
Set the interval between repeats.

Constructor Details

RepeaterCommand

public RepeaterCommand()

RepeaterCommand

public RepeaterCommand(CommandManager commandManager,
                       String commandId)

RepeaterCommand

public RepeaterCommand(String commandId)

Method Details

attach

public void attach(AbstractButton button,
                   String faceName)

detach

public void detach(AbstractButton button)

handleCancel

public abstract void handleCancel()
Method to be executed when the button press is cancelled.

handleFirst

public abstract void handleFirst()
Method to be executed when the button is first pressed.

handleRepeat

public abstract void handleRepeat()
Method to be executed repeatedly while the button is pressed.

setInterval

public void setInterval(int interval)
Set the interval between repeats. Only affects buttons which are still to be created.