net.sourceforge.groboutils.uicapture.v1
Class VirtualWindow

java.lang.Object
  extended bynet.sourceforge.groboutils.uicapture.v1.VirtualWindow
All Implemented Interfaces:
java.util.EventListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener

public class VirtualWindow
extends java.lang.Object
implements java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener

A window which covers the whole screen, and does not paint in the background. It captures keyboard and mouse events, and sends them to both all registered listeners, and to the underlying GUI as well. This transparent window is similar to the "glass pane" concept in Swing JFrames.

For the moment, there is no way for listeners to prevent an event from being passed to the underlying UI. This needs to be changed.

WARNING: if the screen size is to resize, then this will not work correctly.

Since:
Jan 4, 2002
Version:
Mar 13, 2002
Author:
Matt Albrecht groboclown@users.sourceforge.net

Constructor Summary
VirtualWindow()
          Create a new VirtualWindow, with the glass enabled.
VirtualWindow(java.lang.String title, boolean enable)
          Specify the initial enabled state of the window.
 
Method Summary
 void addCaptureListener(ICaptureListener cl)
          Adds an ICaptureListener to the list of recipients of input events.
 java.awt.image.BufferedImage createScreenScrape()
          Scrapes the current screen into a BufferedImage the same size as the window.
 java.awt.image.BufferedImage createScreenScrape(java.awt.Rectangle bounds)
          Scrapes the current screen into a BufferedImage from the given area on the screen.
 void delay(int ms)
          Sleeps for the specified number of milliseconds.
 void dispose()
          Close out all inner instances and shut down the UI
protected  java.util.Iterator getCaptureListeners()
          Returns a list of all the current ICaptureListeners.
 VirtualWindowUI getWindow()
           
 void hide()
          Hides the glass pane, and stops all input event capturing.
 boolean isGlassEnabled()
          Retrieves the current glass enabled state.
 void keyPressed(java.awt.event.KeyEvent ke)
           
 void keyReleased(java.awt.event.KeyEvent ke)
           
 void keyTyped(java.awt.event.KeyEvent me)
           
 void mouseClicked(java.awt.event.MouseEvent me)
           
 void mouseDragged(java.awt.event.MouseEvent me)
           
 void mouseEntered(java.awt.event.MouseEvent me)
           
 void mouseExited(java.awt.event.MouseEvent me)
           
 void mouseMoved(java.awt.event.MouseEvent me)
           
 void mousePressed(java.awt.event.MouseEvent me)
           
 void mouseReleased(java.awt.event.MouseEvent me)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent me)
           
 void removeCaptureListener(ICaptureListener cl)
          Removes the given ICaptureListener from the inner list of input events recipients.
 void setGlassEnabled(boolean on)
          Sets the inner state for displaying the glass pane.
 void show()
          Shows the glass pane, and continues all input event capturing.
 void simulateEvent(CaptureEvent ce)
          Simulates the given captured event.
 void update()
          Updates the background image.
 void waitForIdle()
          Waits until all events currently on the event queue have been processed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VirtualWindow

public VirtualWindow()
              throws java.awt.AWTException
Create a new VirtualWindow, with the glass enabled.

Throws:
java.awt.AWTException - thrown if a Robot is not supported in the current JDK implementation.

VirtualWindow

public VirtualWindow(java.lang.String title,
                     boolean enable)
              throws java.awt.AWTException
Specify the initial enabled state of the window.

Parameters:
enable - set to the initial glass pane state.
Throws:
java.awt.AWTException - thrown if a Robot is not supported in the current JDK implementation.
Method Detail

dispose

public void dispose()
Close out all inner instances and shut down the UI


getWindow

public VirtualWindowUI getWindow()
Returns:
the inner Window reference.

setGlassEnabled

public void setGlassEnabled(boolean on)
Sets the inner state for displaying the glass pane. If the pane is enabled, then the glass pane will attempt to maximize itself and keep itself on the foreground at all costs.

Parameters:
on - true if the glass pane is enabled (active and intercepting events), or false if is disabled.

isGlassEnabled

public boolean isGlassEnabled()
Retrieves the current glass enabled state.

Returns:
true if the glass pane is enabled (active and intercepting events), or false if is disabled.

simulateEvent

public void simulateEvent(CaptureEvent ce)
Simulates the given captured event. This minimizes the glass window, performs the event with the Robot, and restores the glass window if the glass pane is enabled.

Parameters:
ce - the event to simulate.

delay

public void delay(int ms)
Sleeps for the specified number of milliseconds. This is passed directly through to the underlying Robot.

Parameters:
ms - Time to sleep in milliseconds.
Throws:
java.lang.IllegalArgumentException - thrown by Robot if ms is not between 0 and 60,000, inclusive.

waitForIdle

public void waitForIdle()
Waits until all events currently on the event queue have been processed. This is passed directly through to the underlying Robot.


createScreenScrape

public java.awt.image.BufferedImage createScreenScrape()
Scrapes the current screen into a BufferedImage the same size as the window.

Returns:
the captured screen image.

createScreenScrape

public java.awt.image.BufferedImage createScreenScrape(java.awt.Rectangle bounds)
Scrapes the current screen into a BufferedImage from the given area on the screen. This is passed directly to the underlying Robot.

Returns:
the captured screen image.

addCaptureListener

public void addCaptureListener(ICaptureListener cl)
Adds an ICaptureListener to the list of recipients of input events. If the given listener is null, then the request is ignored.

Parameters:
cl - the listener to add.

removeCaptureListener

public void removeCaptureListener(ICaptureListener cl)
Removes the given ICaptureListener from the inner list of input events recipients. If the given listener is null or not registered, then the request is ignored.

Parameters:
cl - the listener to remove.

hide

public void hide()
Hides the glass pane, and stops all input event capturing. This is only executed if the glass is enabled, and has no effect on the enabled state of the glass.


show

public void show()
Shows the glass pane, and continues all input event capturing. This is only executed if the glass is enabled, and has no effect on the enabled state of the glass.


update

public void update()
Updates the background image.


mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent me)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener
See Also:
MouseWheelListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent me)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
See Also:
MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent me)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
See Also:
MouseMotionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Specified by:
mousePressed in interface java.awt.event.MouseListener
See Also:
MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
Specified by:
mouseReleased in interface java.awt.event.MouseListener
See Also:
MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Specified by:
mouseClicked in interface java.awt.event.MouseListener
See Also:
MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent me)
Specified by:
mouseEntered in interface java.awt.event.MouseListener
See Also:
MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)
Specified by:
mouseExited in interface java.awt.event.MouseListener
See Also:
MouseListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent me)
Specified by:
keyTyped in interface java.awt.event.KeyListener
See Also:
KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent ke)
Specified by:
keyPressed in interface java.awt.event.KeyListener
See Also:
KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent ke)
Specified by:
keyReleased in interface java.awt.event.KeyListener
See Also:
KeyListener

getCaptureListeners

protected java.util.Iterator getCaptureListeners()
Returns a list of all the current ICaptureListeners.

Returns:
an iterator of the listeners.


Copyright © 2001-2003 by The GroboUtils Project