Groovy Documentation

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

java.lang.Object
  com.wordpress.tipsforjava.swing.FormScroller
All Implemented Interfaces:
PropertyChangeListener

public class FormScroller
extends Object

The FormScroller will ensure that when a component gains focus it will always be visible within the viewport of the scrollpane.

Authors:
Rob Camick
Darryl Burke


Nested Class Summary
enum FormScroller.Type

 
Field Summary
private Point lastLocation

private Insets scrollInsets

private JScrollPane scrollPane

The FormScroller will ensure that when a component gains focus it will always be visible within the viewport of the scrollpane.

private boolean scrollingEnabled

private FormScroller.Type type

 
Constructor Summary
FormScroller(JScrollPane scrollPane)

Convenience constructor that set the scroll Type to COMPONENT

FormScroller(JScrollPane scrollPane, FormScroller.Type type)

Create a FormScroller for the specified scroll Type

 
Method Summary
private Rectangle determineChildBounds(Component component, JComponent view)

private Rectangle determineComponentBounds(Component component, JComponent view)

private Rectangle determineParentBounds(Component component, JComponent view)

protected Rectangle determineScrollBounds(Component component, JComponent view)

Determine the bounds that must fit into the viewport of the scrollpane

Insets getScrollInsets()

Get the scroll insets.

FormScroller.Type getType()

Get the Type of scrolling to be attempted by the scroller

boolean isScrollingEnabled()

void propertyChange(PropertyChangeEvent evt)

private boolean rectangleFits(Rectangle bounds)

void setScrollInsets(Insets scrollInsets)

Set the scroll insets.

void setScrollingEnabled(boolean scrollingEnabled)

Enable automatic scrolling on the form.

void setType(FormScroller.Type type)

Set the Type of scrolling to be done by the scroller

FormScroller valueOf(String name)

Returns the enum constant of this type with the specified name.

FormScroller[] values()

Returns an array containing the constants of this enum type, in the order they are declared.

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

Field Detail

lastLocation

private Point lastLocation


scrollInsets

private Insets scrollInsets


scrollPane

private JScrollPane scrollPane
The FormScroller will ensure that when a component gains focus it will always be visible within the viewport of the scrollpane.
Authors:
Rob Camick
Darryl Burke


scrollingEnabled

private boolean scrollingEnabled


type

private FormScroller.Type type


 
Constructor Detail

FormScroller

public FormScroller(JScrollPane scrollPane)
Convenience constructor that set the scroll Type to COMPONENT


FormScroller

public FormScroller(JScrollPane scrollPane, FormScroller.Type type)
Create a FormScroller for the specified scroll Type


 
Method Detail

determineChildBounds

private Rectangle determineChildBounds(Component component, JComponent view)


determineComponentBounds

private Rectangle determineComponentBounds(Component component, JComponent view)


determineParentBounds

private Rectangle determineParentBounds(Component component, JComponent view)


determineScrollBounds

protected Rectangle determineScrollBounds(Component component, JComponent view)
Determine the bounds that must fit into the viewport of the scrollpane
Parameters:
component - the component that currently has focus
view - the component added to the viewport of the scrollpane
Returns:
a Rectangle representing the bounds to be scrolled


getScrollInsets

public Insets getScrollInsets()
Get the scroll insets.
Returns:
the scroll insets


getType

public FormScroller.Type getType()
Get the Type of scrolling to be attempted by the scroller


isScrollingEnabled

public boolean isScrollingEnabled()


propertyChange

de
	public
public void propertyChange(PropertyChangeEvent evt)


rectangleFits

private boolean rectangleFits(Rectangle bounds)


setScrollInsets

public void setScrollInsets(Insets scrollInsets)
Set the scroll insets. The scroller will attempt to leave a gap between the scrolled Container and the edge of the scrollpane.
paran:
scrollInsets - Insets for the gap for each edge of the scrollpane


setScrollingEnabled

public void setScrollingEnabled(boolean scrollingEnabled)
Enable automatic scrolling on the form.
Parameters:
scrollingEnabled - enable/disable scrolling


setType

public void setType(FormScroller.Type type)
Set the Type of scrolling to be done by the scroller Type.COMPONENT - the focused component should be visible in the viewport. Type.PARENT - the parent Container of the focus component should be visible in the viewport. If the parent Container does not fit completely then use Type.COMPONENT. Type.CHILD - the child Contaier of the viewport view component which contains the focused component should be visible in the viewport. If the child Container does not fit completely then use Type.PARENT.
Parameters:
Type - - controls scrolling of the viewport (values given above)


valueOf

FormScroller valueOf(String name)
Returns the enum constant of this type with the specified name.


values

FormScroller[] values()
Returns an array containing the constants of this enum type, in the order they are declared.


 

Groovy Documentation