|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ccg.swing.TextUtils
public class TextUtils
General utility methods for working with text components.
This class provides some static helper methods that provide some convienent "wrappers" dealing with the setting and retrieving of values from text fields. In particular these methods provide a consistent manner for dealing with 'null' values.
| Constructor Summary | |
|---|---|
TextUtils()
|
|
| Method Summary | |
|---|---|
static File |
getFileOrNull(JTextComponent c)
Get a File object from the text of a component (or
null if text is blank). |
static String |
getStringOrNull(JTextComponent c)
Get a text string from a component (or null if text is blank). |
static void |
setFileOrNull(JTextComponent c,
File val)
Set the text value of a component from a file (which might be null). |
static void |
setStringOrNull(JTextComponent c,
String val)
Set the text value of a component from a string (which might be null). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TextUtils()
| Method Detail |
|---|
public static void setStringOrNull(JTextComponent c,
String val)
This method is designed to work in conjustion with the getStringOrNull(javax.swing.text.JTextComponent) method. It allows one to set/retrieve 'null'
string values from components. If you pass null to this method as
the value, we will change it to the zero length string "".
c - The component to set the text value on (you
can pass null - and we'll handle it)val - String value to assign - if you pass null, we'll set the
text to "".getStringOrNull(javax.swing.text.JTextComponent)public static String getStringOrNull(JTextComponent c)
This method is the counter part to the setStringOrNull(javax.swing.text.JTextComponent, java.lang.String) method. It retrieves the current text setting
from the component. If the current setting is just white space,
then this method return null - otherwise it returns the value of
the text shown in the component.
c - The component to get the text value from
(you can pass null - and we'll handle it)
setStringOrNull(javax.swing.text.JTextComponent, java.lang.String)
public static void setFileOrNull(JTextComponent c,
File val)
This method is designed to work in conjuction with the getFileOrNull(javax.swing.text.JTextComponent) method. It allows one to set/retrieve 'null'
file values from components.
This method will set the text value of the component to the
string representation of the File object you
pass. If you pass null to this method as the value, we will
change it to the zero length file "".
c - The component to set the text value on (you
can pass null - and we'll handle it)val - File object to get the text from - if you pass null, we'll
set the text to "".getFileOrNull(javax.swing.text.JTextComponent)public static File getFileOrNull(JTextComponent c)
File object from the text of a component (or
null if text is blank).
This method is the counter part to the setFileOrNull(javax.swing.text.JTextComponent, java.io.File)
method. It retrieves the current text setting from the component
as a File object. If the current setting is just
white space, then this method returns null - otherwise it returns
a File object with the value of the text shown in
the component.
c - The component to fetch the text from (you
can pass null - and we'll handle it)
File object formed from the text of the
component - or null if component's text is just white space.setFileOrNull(javax.swing.text.JTextComponent, java.io.File)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||