Orbital library

orbital.moon.awt
Class SystemRequestor

java.lang.Object
  extended by java.awt.event.KeyAdapter
      extended by orbital.moon.awt.SystemRequestor
All Implemented Interfaces:
java.awt.event.KeyListener, java.util.EventListener

public class SystemRequestor
extends java.awt.event.KeyAdapter

This class is a SystemRequestor that will call a predicate on interrupt or abort requests when registered as a key listener.

Use one of:

 component.addKeyListener(new SystemRequestor(reactorPredicate));
 new SystemRequestor(reactorPredicate, component);
 

Note that if you intend to let the predicate abort the application without further user feedback SystemRequestor needs being the first key listener to notify.

Author:
André Platzer

Field Summary
static int ABORT
           
static int INTERRUPT
           
protected  Predicate request
           
 
Constructor Summary
SystemRequestor(Predicate requestReactor)
          Construct a SystemRequestor calling the given predicate on interrupt and abort requests.
SystemRequestor(Predicate requestReactor, java.awt.Component comp)
          Construct a SystemRequestor calling the given predicate on interrupt and abort requests.
 
Method Summary
 void keyPressed(java.awt.event.KeyEvent e)
          Check for Abort and Interrupt requests.
 
Methods inherited from class java.awt.event.KeyAdapter
keyReleased, keyTyped
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERRUPT

public static final int INTERRUPT
See Also:
Constant Field Values

ABORT

public static final int ABORT
See Also:
Constant Field Values

request

protected Predicate request
Constructor Detail

SystemRequestor

public SystemRequestor(Predicate requestReactor)
Construct a SystemRequestor calling the given predicate on interrupt and abort requests.

Parameters:
requestReactor - the predicate called when an interrupt or abort request occured. This predicate can perform the corresponding operations to interrupt running thread or abort the program.

SystemRequestor

public SystemRequestor(Predicate requestReactor,
                       java.awt.Component comp)
Construct a SystemRequestor calling the given predicate on interrupt and abort requests. Automatically registers as a key listener of the component specified.

Parameters:
requestReactor - the predicate called when an interrupt or abort request occured. This predicate can perform the corresponding operations to interrupt running thread or abort the program.
comp - the component to register to.
Method Detail

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Check for Abort and Interrupt requests.

Specified by:
keyPressed in interface java.awt.event.KeyListener
Overrides:
keyPressed in class java.awt.event.KeyAdapter

Orbital library
1.3.0: 11 Apr 2009

Copyright © 1996-2009 André Platzer
All Rights Reserved.