com.glaivestone.javax.swing
Class SwingServices

java.lang.Object
  |
  +--com.glaivestone.javax.swing.SwingServices

public class SwingServices
extends java.lang.Object

General-purpose utility services for Swing UI operations.

Services are invoked through SwingServices.current.

Since:
GFL 1.1
Author:
Deb Lewis

Field Summary
static SwingServices current
           
 
Method Summary
 java.awt.Rectangle adjustTargetHeight(java.awt.Rectangle targetRect, int dyAbove, int dyBelow)
          Adjust the height of a target area in a view to allow additional height above or below.
 void applyLabelLookAndFeel(javax.swing.JTextArea aTextItem)
          Make a multi-line text area have the look-and-feel of a single-line label.
 void applyReadOnlyLookAndFeel(javax.swing.text.JTextComponent aTextItem)
          Make a text item have the look-and-feel of a read-only item.
 int getLineStartOffset(int offset, javax.swing.JTextArea textComponent)
          Answer the offset of the start of the line containing the specified location.
 boolean scrollItemIntoView(int index, javax.swing.JList listComponent)
          Scroll the item at the specified position in the list into view.
 boolean scrollRowIntoView(int index, javax.swing.JTable tableComponent)
          Scroll the row at the specified position in the table into view.
 boolean scrollRowIntoView(int index, javax.swing.JTable tableComponent, int rowsAbove, int rowsBelow)
          Scroll the row at the specified position in the table into view.
 boolean scrollSelectionIntoView(javax.swing.JList listComponent)
          Scroll the selected item in the list into view.
 boolean scrollSelectionIntoView(javax.swing.JTable tableComponent)
          Scroll the selected row in the table into view.
 boolean scrollTextIntoView(int offset, javax.swing.JScrollPane textViewScroller)
          Scroll the text starting at the specified offset into view
 boolean scrollTextIntoView(int offset, javax.swing.JScrollPane textViewScroller, int linesAbove, int linesBelow)
          Scroll the text starting at the specified offset into view
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current

public static SwingServices current
Method Detail

adjustTargetHeight

public java.awt.Rectangle adjustTargetHeight(java.awt.Rectangle targetRect,
                                             int dyAbove,
                                             int dyBelow)
Adjust the height of a target area in a view to allow additional height above or below.

Parameters:
targetRect - The target area to adjust
dyAbove - Desired amount of additional height above the target.
dyBelow - Desired amount of additional height above the target.
Returns:
new Rectangle for adjusted target area

applyLabelLookAndFeel

public void applyLabelLookAndFeel(javax.swing.JTextArea aTextItem)
Make a multi-line text area have the look-and-feel of a single-line label.


applyReadOnlyLookAndFeel

public void applyReadOnlyLookAndFeel(javax.swing.text.JTextComponent aTextItem)
Make a text item have the look-and-feel of a read-only item.


getLineStartOffset

public int getLineStartOffset(int offset,
                              javax.swing.JTextArea textComponent)
Answer the offset of the start of the line containing the specified location.

Returns -1 if an invalid location in the text is specified or the position cannot be resolved.


scrollItemIntoView

public boolean scrollItemIntoView(int index,
                                  javax.swing.JList listComponent)
Scroll the item at the specified position in the list into view.

Parameters:
index - Position in the list of the item that should be in view
listComponent - The list component
Returns:
whether the item is now visible

scrollRowIntoView

public boolean scrollRowIntoView(int index,
                                 javax.swing.JTable tableComponent)
Scroll the row at the specified position in the table into view.

Parameters:
index - Position in the table of the row that should be in view
tableComponent - The table component
Returns:
whether the item is now visible

scrollRowIntoView

public boolean scrollRowIntoView(int index,
                                 javax.swing.JTable tableComponent,
                                 int rowsAbove,
                                 int rowsBelow)
Scroll the row at the specified position in the table into view. The requested number of pad rows are also scrolled above and below the target row.

Parameters:
rowsAbove - Number of extra rows above the location that should be left in view
rowsBelow - Number of extra rows below the location that should be left in view

scrollSelectionIntoView

public boolean scrollSelectionIntoView(javax.swing.JList listComponent)
Scroll the selected item in the list into view.

Parameters:
listComponent - The list component
Returns:
whether the item is now visible

scrollSelectionIntoView

public boolean scrollSelectionIntoView(javax.swing.JTable tableComponent)
Scroll the selected row in the table into view.

Parameters:
tableComponent - The table component
Returns:
whether the item is now visible

scrollTextIntoView

public boolean scrollTextIntoView(int offset,
                                  javax.swing.JScrollPane textViewScroller)
Scroll the text starting at the specified offset into view

Does nothing if the text is already in view or an invalid location in the text is specified.

Parameters:
offset - Offset in the text that should be in view
textViewScroller - Scroller containing the text component
Returns:
whether the text is now visible

scrollTextIntoView

public boolean scrollTextIntoView(int offset,
                                  javax.swing.JScrollPane textViewScroller,
                                  int linesAbove,
                                  int linesBelow)
Scroll the text starting at the specified offset into view

Does nothing if the text is already in view or an invalid location in the text is specified.

Parameters:
offset - Offset in the text that should be in view
textViewScroller - Scroller containing the text component
linesAbove - Number of extra lines above the location that should be left in view
linesBelow - Number of extra lines below the location that should be left in view
Returns:
whether the text is now visible

GFL 1.1 API