PIRL.Viewers

## Class Blinker

- java.lang.Object
- - javax.swing.Timer
  - - PIRL.Viewers.Blinker

All Implemented Interfaces:
  ActionListener, Serializable, EventListener

    public class Blinker
    extends Timer
    implements ActionListener

An ActionListener for blinking a component to make it stand out from the crowd.

Blinking occurs by setting the background color of the component to a specified color, and then returning to the original color, with a delay interval between background color switching. This on-off cycle is repeated for a specified number of times, or until instructed to stop. An optional delay after the new background color is first switched on until the blinking intervals start may be specified.

See Also:
  Serialized Form

### Field Summary

Fields
`static Color` `COLOR` The default background Color to use when the component is blinked "on": yellow.
`static int` `INDEFINITELY` Constant to specify an indefinate number of blinks; i.e. forever until stopped.
`static int` `INITIAL_DELAY` The default initial delay before blinking starts: 0 milliseconds (immediately after start).
`static int` `INTERVAL` The default blink interval: 500 milliseconds (half a second).
`static int` `MINIMUM_INTERVAL` The minimum blink interval: 100 milliseconds.
`static int` `REPEATS` The default number of blink repeats: INDEFINITELY.

### Fields inherited from class javax.swing.Timer

`listenerList`

### Constructor Summary

Constructors
Constructor and Description
`Blinker()` Constructs a disabled Blinker with default Blinker parameters.
`Blinker(Component component)` Constructs a Blinker for the component using all of the default Blinker parameters.
`Blinker(Component component, Color color, int repeats, int initial_delay, int interval)` Constructs a component Blinker.

### Method Summary

Methods
`void` `actionPerformed(ActionEvent event)` Performs the blink event at the Timer interval.
`Color` `getColor()` Gets the background color that will be used when blinking the component.
`Component` `getComponent()` Gets the Component to be blinked.
`int` `getRepeats()` Gets the maximum number of blinks.
`void` `restart()` Restarts the Blinker as if no blinks had occured.
`Color` `setColor(Color color)` Sets the background color to use when blinking the component.
`Blinker` `setComponent(Component component)` Sets the Component to be blinked.
`int` `setRepeats(int repeats)` Sets the maximum number of blinks.
`void` `start()` Turns the component "on" (sets the new background color) and starts the blink timer.
`void` `stop()` Stops the blink timer and turns the component "off" (sets the original background color).

### Methods inherited from class javax.swing.Timer

`addActionListener, fireActionPerformed, getActionCommand, getActionListeners, getDelay, getInitialDelay, getListeners, getLogTimers, isCoalesce, isRepeats, isRunning, removeActionListener, setActionCommand, setCoalesce, setDelay, setInitialDelay, setLogTimers, setRepeats`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### INDEFINITELY

    public static final int INDEFINITELY

Constant to specify an indefinate number of blinks; i.e. forever until stopped.

See Also:
  Constant Field Values

#### REPEATS

    public static final int REPEATS

The default number of blink repeats: INDEFINITELY.

See Also:
  Constant Field Values

#### INITIAL_DELAY

    public static final int INITIAL_DELAY

The default initial delay before blinking starts: 0 milliseconds (immediately after start).

See Also:
  Constant Field Values

#### INTERVAL

    public static final int INTERVAL

The default blink interval: 500 milliseconds (half a second).

See Also:
  Constant Field Values

#### MINIMUM_INTERVAL

    public static final int MINIMUM_INTERVAL

The minimum blink interval: 100 milliseconds.

See Also:
  Constant Field Values

#### COLOR

    public static final Color COLOR

The default background Color to use when the component is blinked "on": yellow.

### Constructor Detail

#### Blinker

    public Blinker(Component component,
           Color color,
           int repeats,
           int initial_delay,
           int interval)

Constructs a component Blinker.

Parameters:
  `component` - The Component to be blinked.
  `color` - The Color to set the component background when it is blinked "on".
  `repeats` - The maximum number of blinks. Use the ``INDEFINITELY`` value to continue blinking until stopped.
  `initial_delay` - The initial delay, after the component is turned on, before starting to blink. A value <= 0 means no initial delay.
  `interval` - The interval between blinks (on to off, or off to on). A `MINIMUM_INTERVAL` is enforced.

#### Blinker

    public Blinker(Component component)

Constructs a Blinker for the component using all of the default Blinker parameters.

Parameters:
  `component` - The Component to be blinked.

#### Blinker

    public Blinker()

Constructs a disabled Blinker with default Blinker parameters.

### Method Detail

#### start

    public void start()

Turns the component "on" (sets the new background color) and starts the blink timer. The blink count picks up from its previous value. Use restart to reset the blink count.

Overrides:
  `start` in class `Timer`

#### stop

    public void stop()

Stops the blink timer and turns the component "off" (sets the original background color). The blink count is not reset.

Overrides:
  `stop` in class `Timer`

#### restart

    public void restart()

Restarts the Blinker as if no blinks had occured.

Overrides:
  `restart` in class `Timer`

#### setRepeats

    public int setRepeats(int repeats)

Sets the maximum number of blinks.

Parameters:
  `repeats` - The maximum number of times to blink the component. Use the ``INDEFINITELY`` value to continue blinking until stopped.
Returns:
  The previous value.

#### getRepeats

    public int getRepeats()

Gets the maximum number of blinks.

Returns:
  The maximum number of times to blink the component. For indefinate blinking this will be the ``INDEFINITELY`` value.

#### setColor

    public Color setColor(Color color)

Sets the background color to use when blinking the component.

Parameters:
  `color` - The background color when the component is "on".
Returns:
  The previous value.

#### getColor

    public Color getColor()

Gets the background color that will be used when blinking the component.

Returns:
  The background blink Color.

#### setComponent

    public Blinker setComponent(Component component)

Sets the Component to be blinked.

Any currently blinking component is stopped and the blink count is reset to zero. The new component will not yet be blinking.

Parameters:
  `component` - The Component to be blinked.
Returns:
  This blinker.

#### getComponent

    public Component getComponent()

Gets the Component to be blinked.

Returns:
  The Component to be blinked.

#### actionPerformed

    public void actionPerformed(ActionEvent event)

Performs the blink event at the Timer interval. Switches the component from its "on" background color to its "off" background color, or vice versa.

Specified by:
  `actionPerformed` in interface `ActionListener`