Groovy Documentation

com.wordpress.tipsforjava.swing
[Java] Class CaretPositionListener

java.lang.Object
  com.wordpress.tipsforjava.swing.CaretPositionListener
All Implemented Interfaces:
MouseListener

public class CaretPositionListener
extends Object

This class will retain the caret positioning at the character where the mouse was clicked.

Authors:
Rob Camick
Darryl Burke


Field Summary
private boolean dynamicFormatting

 
Constructor Summary
CaretPositionListener()

Default constructor.

CaretPositionListener(JFormattedTextField... components)

Convenience constructor.

 
Method Summary
void deregisterComponent(JFormattedTextField... components)

Remove listeners from the specified component

private void determineCaretPosition(JFormattedTextField ftf)

boolean isDynamicFormatting()

void mouseClicked(MouseEvent e)

void mouseEntered(MouseEvent e)

void mouseExited(MouseEvent e)

void mousePressed(MouseEvent me)

void mouseReleased(MouseEvent e)

void registerComponent(JFormattedTextField... components)

Add the required listeners to the specified component

private void setCaretPosition(JFormattedTextField ftf, int offset)

void setDynamicFormatting(boolean dynamicFormatting)

Indicates that the formatting of the text in the formatted text field can change depending on whether the text field has focus or not.

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

dynamicFormatting

private boolean dynamicFormatting


 
Constructor Detail

CaretPositionListener

public CaretPositionListener()
Default constructor.


CaretPositionListener

public CaretPositionListener(JFormattedTextField... components)
Convenience constructor. This class is automatically added as a MouseListener to the specified formatted text fields.


 
Method Detail

deregisterComponent

public void deregisterComponent(JFormattedTextField... components)
Remove listeners from the specified component
Parameters:
component - the component the listeners are removed from


determineCaretPosition

private void determineCaretPosition(JFormattedTextField ftf)


isDynamicFormatting

public boolean isDynamicFormatting()


mouseClicked

public void mouseClicked(MouseEvent e)


mouseEntered

public void mouseEntered(MouseEvent e)


mouseExited

public void mouseExited(MouseEvent e)


mousePressed

public void mousePressed(MouseEvent me)


mouseReleased

public void mouseReleased(MouseEvent e)


registerComponent

public void registerComponent(JFormattedTextField... components)
Add the required listeners to the specified component
Parameters:
component - the component the listeners are added to


setCaretPosition

private void setCaretPosition(JFormattedTextField ftf, int offset)


setDynamicFormatting

public void setDynamicFormatting(boolean dynamicFormatting)
Indicates that the formatting of the text in the formatted text field can change depending on whether the text field has focus or not. The listner must be aware of this so the proper caret position can be calculated.
Parameters:
dynamicFormatting - when true dynamic formatting must be considered


 

Groovy Documentation