org.formaria.event
Class ClickListener

java.lang.Object
  extended by org.formaria.event.ClickListener
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener

public class ClickListener
extends java.lang.Object
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

Adds mouse support for clickable controls/regions

Copyright (c) Formaria Ltd., 2008, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from Formaria.

$Revision: 1.6 $


Constructor Summary
ClickListener(java.awt.Component ownr)
          Constructs a simple listener that tracks the state of a check mark
ClickListener(java.awt.Component ownr, int startPos)
          Constructs a listener that can track the state of multiple checkmarks.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener l)
          Adds the specified action listener to receive action events from this button.
 int getActiveResponse()
          Gets the active response for a listener tracking multiple check marks.
 java.awt.Point getClickLocation()
          Get the location of the mouse click
 boolean getIsEntered()
          Gets the entered state of the owner control
 boolean getIsSelected()
          Gets the selected state of the owner control
 int getSelectedResponse()
          Gets the selected response for a listener tracking multiple check marks.
 void mouseClicked(java.awt.event.MouseEvent e)
          Calls the owner's parent responsToEvent method with BUTTON_CLCIKED as the event id
 void mouseDragged(java.awt.event.MouseEvent e)
          Tracks the mouse position of the owner control
 void mouseEntered(java.awt.event.MouseEvent e)
          Tracks the entered state of the owner control
 void mouseExited(java.awt.event.MouseEvent e)
          Tracks the entered state of the owner control
 void mouseMoved(java.awt.event.MouseEvent e)
          Tracks the mouse position of the owner control
 void mousePressed(java.awt.event.MouseEvent e)
          Tracks the mouse pressed state of the owner control
 void mouseReleased(java.awt.event.MouseEvent e)
          Tracks the mouse pressed state of the owner control
protected  void processActionEvent(java.awt.event.ActionEvent e)
          Processes action events occurring on this button by dispatching them to any registered ActionListener objects.
 void removeActionListener(java.awt.event.ActionListener l)
          Removes the specified action listener so that it no longer receives action events from this button.
 void reset()
          Resets the listener's state
 void setActiveResponse(int resp)
          Set the active response
 void setCancelOnDrag(boolean state)
          Set the cancelOnDrag flag.
 void setIsSelected(boolean selected)
          Sets the selected state of the owner control
 void setOffset(int off)
          Sets the offset to the first check mark
 void setSelectedResponse(int resp)
          Sets the selected response
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClickListener

public ClickListener(java.awt.Component ownr)
Constructs a simple listener that tracks the state of a check mark

Parameters:
ownr - The component to which this listener listens

ClickListener

public ClickListener(java.awt.Component ownr,
                     int startPos)
Constructs a listener that can track the state of multiple checkmarks.

Parameters:
ownr - The component to which this listener listens
startPos - The offset to the first check mark
Method Detail

reset

public void reset()
Resets the listener's state


mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Calls the owner's parent responsToEvent method with BUTTON_CLCIKED as the event id

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
e -

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Tracks the entered state of the owner control

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
e -

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Tracks the entered state of the owner control

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e -

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Tracks the mouse pressed state of the owner control

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e -

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Tracks the mouse pressed state of the owner control

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e -

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Tracks the mouse position of the owner control

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
e -

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Tracks the mouse position of the owner control

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e -

setOffset

public void setOffset(int off)
Sets the offset to the first check mark

Parameters:
off -

getIsEntered

public boolean getIsEntered()
Gets the entered state of the owner control

Returns:
the entered state of the owner control

getIsSelected

public boolean getIsSelected()
Gets the selected state of the owner control

Returns:
the selected state of the owner control

setIsSelected

public void setIsSelected(boolean selected)
Sets the selected state of the owner control

Parameters:
selected - the new state of the owner control

getActiveResponse

public int getActiveResponse()
Gets the active response for a listener tracking multiple check marks. The active response is the one under the mouse

Returns:
the active response

setActiveResponse

public void setActiveResponse(int resp)
Set the active response

Parameters:
resp - the new active response

getSelectedResponse

public int getSelectedResponse()
Gets the selected response for a listener tracking multiple check marks. The selected response is the one that has been checked or clicked.

Returns:
the selected response or -1 if nothing is selected

setSelectedResponse

public void setSelectedResponse(int resp)
Sets the selected response

Parameters:
resp - the new selection

setCancelOnDrag

public void setCancelOnDrag(boolean state)
Set the cancelOnDrag flag. If true the selected state of the listener is reset upon a drag operation

Parameters:
state - true to reset the state

getClickLocation

public java.awt.Point getClickLocation()
Get the location of the mouse click

Returns:
the location of the mouse click

addActionListener

public void addActionListener(java.awt.event.ActionListener l)
Adds the specified action listener to receive action events from this button. Action events occur when a user presses or releases the mouse over this button. If l is null, no exception is thrown and no action is performed.

Parameters:
l - the action listener
Since:
JDK1.1
See Also:
removeActionListener(java.awt.event.ActionListener), #getActionListeners, ActionListener

removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)
Removes the specified action listener so that it no longer receives action events from this button. Action events occur when a user presses or releases the mouse over this button. If l is null, no exception is thrown and no action is performed.

Parameters:
l - the action listener
Since:
JDK1.1
See Also:
addActionListener(java.awt.event.ActionListener), #getActionListeners, ActionListener

processActionEvent

protected void processActionEvent(java.awt.event.ActionEvent e)
Processes action events occurring on this button by dispatching them to any registered ActionListener objects.

This method is not called unless action events are enabled for this button. Action events are enabled when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception.

Parameters:
e - the action event
Since:
JDK1.1
See Also:
ActionListener, Button.addActionListener(java.awt.event.ActionListener), Component.enableEvents(long)