eTextReader
Class PasteListener

java.lang.Object
  extended by eTextReader.PasteListener
All Implemented Interfaces:
java.awt.event.FocusListener, java.util.EventListener

public class PasteListener
extends java.lang.Object
implements java.awt.event.FocusListener

A class to monitor the currently focussed JTextComponent amoung those that register an instance of PasteListener as a FocusListener.

Version:
1.0
Author:
Josh Morse

Field Summary
private  javax.swing.text.JTextComponent currentcomp
          A JTextComponent representing the current focus ownner.
private  javax.swing.text.JTextComponent lastcomp
          A JTextComponent representing the last focus owner.
private  boolean verbose
          If this boolean is true, print status messages to the console.
 
Constructor Summary
PasteListener()
          Constructs a paste listener that monitors the currently focussed component with a default verbose value of false.
PasteListener(boolean verbose)
          Constructs a paste listener that monitors the currently focussed component.
 
Method Summary
 void focusGained(java.awt.event.FocusEvent e)
          Updates currentcomp based on the newly focussed component.
 void focusLost(java.awt.event.FocusEvent e)
          Inherited.
 javax.swing.text.JTextComponent getCurrentComponent()
          Returns currentcomp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentcomp

private javax.swing.text.JTextComponent currentcomp
A JTextComponent representing the current focus ownner.


lastcomp

private javax.swing.text.JTextComponent lastcomp
A JTextComponent representing the last focus owner.


verbose

private boolean verbose
If this boolean is true, print status messages to the console.

Constructor Detail

PasteListener

public PasteListener()
Constructs a paste listener that monitors the currently focussed component with a default verbose value of false.


PasteListener

public PasteListener(boolean verbose)
Constructs a paste listener that monitors the currently focussed component.

Parameters:
verbose - sets verbose to the given value.
Method Detail

focusGained

public void focusGained(java.awt.event.FocusEvent e)
Updates currentcomp based on the newly focussed component. Throws a ClassCastException if the component is not a JTextComponent.

Specified by:
focusGained in interface java.awt.event.FocusListener
Parameters:
e - the FocusEvent fired by the component that is the focus owner.

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Inherited. Called if a component loses focus ownership and sets currentcomp to null.

Specified by:
focusLost in interface java.awt.event.FocusListener
Parameters:
e - the FocusEvent fired by the component that lost focus ownership.

getCurrentComponent

public javax.swing.text.JTextComponent getCurrentComponent()
Returns currentcomp