Groovy Documentation

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

java.lang.Object
  com.wordpress.tipsforjava.swing.VisibleCaretListener
All Implemented Interfaces:
CaretListener

public class VisibleCaretListener
extends Object

Simple class to ensure that the caret is visible within the viewport of the scrollpane. This is the normal situation. However, I've noticed that solutions that attempt to turn a text pane into a non wrapping text pane will result in the caret not being visible when adding text to the right edge of the viewport. In general, this class can be used any time you wish to increase the number of visible pixels after the caret on the right edge of a scroll pane.

Authors:
Rob Camick
Darryl Burke


Field Summary
private int visiblePixels

 
Constructor Summary
VisibleCaretListener()

Convenience constructor to create a VisibleCaretListener using the default value for visible pixels, which is set to 2.

VisibleCaretListener(int visiblePixels)

Create a VisibleCaretListener.

 
Method Summary
void caretUpdate(CaretEvent e)

int getVisiblePixels()

Get the number of visble pixels displayed after the Caret.

void setVisiblePixels(int visiblePixels)

Control the number of pixels that should be visible in the viewport after the caret position.

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

Field Detail

visiblePixels

private int visiblePixels


 
Constructor Detail

VisibleCaretListener

public VisibleCaretListener()
Convenience constructor to create a VisibleCaretListener using the default value for visible pixels, which is set to 2.


VisibleCaretListener

public VisibleCaretListener(int visiblePixels)
Create a VisibleCaretListener.
Parameters:
pixels - the number of visible pixels after the caret.


 
Method Detail

caretUpdate

public void caretUpdate(CaretEvent e)


getVisiblePixels

public int getVisiblePixels()
Get the number of visble pixels displayed after the Caret.
Returns:
the number of visible pixels after the caret.


setVisiblePixels

public void setVisiblePixels(int visiblePixels)
Control the number of pixels that should be visible in the viewport after the caret position.
Parameters:
pixels - the number of visible pixels after the caret.


 

Groovy Documentation