|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jext.Utilities
This class contains a bunch of methods, useful for the programmer.
Jext
Field Summary | |
static java.lang.String |
JDK_VERSION
JDK release version. |
static int |
OPEN
This constant defines an open dialog box. |
static int |
SAVE
This constant defines a save dialog box. |
static int |
SCRIPT
This constant defines an open dialog box. |
Constructor Summary | |
Utilities()
|
Method Summary | |
static void |
beep()
Used to 'beep' the user. |
static boolean |
beginsWithRoot(java.lang.String path)
It can be necessary to check if a path specified by the user is an absolute path (i.e C:\Gfx\3d\Utils is absolute whereas ..\Jext is relative). |
static void |
centerComponent(java.awt.Component compo)
A very nice trick is to center windows on screen, this method helps you to to that. |
static void |
centerComponentChild(java.awt.Component parent,
java.awt.Component child)
A very nice trick is to center dialog with their parent. |
static java.lang.String |
chooseFile(java.awt.Component owner,
int mode)
Display a file chooser dialog box. |
static java.lang.String[] |
chooseFiles(java.awt.Component owner,
int mode)
Display a file chooser dialog box and returns selected files. |
static java.lang.String |
classToFile(java.lang.String name)
Converts a clas name to a file name. |
static java.lang.String |
constructPath(java.lang.String change)
Constructs a new path from current user path. |
static java.lang.String |
createWhiteSpace(int len)
Create a blank String made of spaces. |
static java.lang.String |
createWhiteSpace(int len,
int tabSize)
Create a blank String made of tabs. |
static java.lang.String |
fileToClass(java.lang.String name)
Converts a file name to a class name. |
static java.lang.String |
getHomeDirectory()
Returns user's home directory. |
static javax.swing.ImageIcon |
getIcon(java.lang.String picture,
java.lang.Class source)
We may need to load and display images. |
static java.awt.Image |
getImage(java.lang.String picture,
java.lang.Class source)
We may need to load and display images. |
static int |
getLeadingWhiteSpace(java.lang.String str)
Returns the number of leading white space characters in the specified string. |
static int |
getLeadingWhiteSpaceWidth(java.lang.String str,
int tabSize)
Returns the width of the leading white space in the specified string. |
static int |
getRealLength(java.lang.String str,
int tabSize)
|
static java.lang.String |
getRoot(java.lang.String path)
It can be necessary to determine which is the root of a path. |
static java.awt.Dimension |
getScreenDimension()
This methods is used to determine screen's dimensions. |
static java.lang.String |
getShortStringOf(java.lang.String longString,
int maxLength)
Some String can be too long to be correctly displayed on the screen. |
static java.lang.String |
getUserDirectory()
Returns user directory. |
static java.lang.String[] |
getWildCardMatches(java.lang.String s,
boolean sort)
When the user has to specify file names, he can use wildcards (*, ?). |
static java.lang.String[] |
getWildCardMatches(java.lang.String path,
java.lang.String s,
boolean sort)
When the user has to specify file names, he can use wildcards (*, ?). |
static java.lang.String |
globToRE(java.lang.String glob)
Turns a Un*x glob filter to regexp one |
static java.io.File[] |
listFiles(java.lang.String[] names,
boolean construct)
Lists content of a directory. |
static java.io.File[] |
listFiles(java.lang.String[] names,
java.lang.String path,
boolean construct)
Lists content of a directory. |
static boolean |
match(java.lang.String pattern,
java.lang.String string)
This method can determine if a String matches a pattern of wildcards |
static void |
setCursorOnWait(java.awt.Component comp,
boolean on)
Long operations need to display an hourglass. |
static void |
showError(java.lang.String message)
Display an error message in a dialog box. |
static void |
showMessage(java.lang.String message)
Display a sample message in a dialog box. |
static void |
showMessage(java.lang.String title,
java.lang.String message)
Display a sample message in a dialog box. |
static void |
sortStrings(java.lang.String[] strings)
Deprecated. Use the standard Java java.util.Array.sort instead. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int OPEN
public static final int SAVE
public static final int SCRIPT
public static final java.lang.String JDK_VERSION
Constructor Detail |
public Utilities()
Method Detail |
public static void showMessage(java.lang.String message)
message
- The message to displaypublic static void showError(java.lang.String message)
message
- The message to displaypublic static void showMessage(java.lang.String title, java.lang.String message)
message
- The message to displaypublic static java.awt.Dimension getScreenDimension()
Dimension
object containing screen's resolutionpublic static void centerComponent(java.awt.Component compo)
compo
- The Component
to centerpublic static void centerComponentChild(java.awt.Component parent, java.awt.Component child)
parent
- The parent Component
child
- The Component
to centerpublic static java.lang.String classToFile(java.lang.String name)
name
- The class namepublic static java.lang.String fileToClass(java.lang.String name)
name
- The file namepublic static void beep()
public static void setCursorOnWait(java.awt.Component comp, boolean on)
comp
- The JComponent
on which to apply the hour glass cursoron
- If true, we set the cursor on the hourglasspublic static javax.swing.ImageIcon getIcon(java.lang.String picture, java.lang.Class source)
picture
- The path to the imagesource
- The class 'root'
ImageIcon
public static java.awt.Image getImage(java.lang.String picture, java.lang.Class source)
picture
- The path to the imagesource
- The class 'root'
Image
public static java.lang.String[] chooseFiles(java.awt.Component owner, int mode)
owner
- Component
which 'owns' the dialogmode
- Can be either OPEN
, SCRIPT
or SAVE
public static java.lang.String chooseFile(java.awt.Component owner, int mode)
owner
- Component
which 'owns' the dialogmode
- Can be either OPEN
, SCRIPT
or SAVE
public static java.lang.String createWhiteSpace(int len)
len
- Amount of spaces contained in the String
String
public static java.lang.String createWhiteSpace(int len, int tabSize)
len
- Amount of spaces contained in the StringtabSize
- Tabulation size
String
public static int getLeadingWhiteSpace(java.lang.String str)
str
- The stringpublic static int getLeadingWhiteSpaceWidth(java.lang.String str, int tabSize)
str
- The stringtabSize
- The tab sizepublic static int getRealLength(java.lang.String str, int tabSize)
public static java.lang.String getShortStringOf(java.lang.String longString, int maxLength)
longString
- The String
to be truncatedmaxLength
- The maximum length of the String
public static java.lang.String constructPath(java.lang.String change)
change
is equal
to C:\Jdk, constructPath will return C:\Jdk).
change
- The modification to apply to the pathpublic static boolean beginsWithRoot(java.lang.String path)
path
- The path to check
true
if path
begins with a root namepublic static java.lang.String getUserDirectory()
public static java.lang.String getHomeDirectory()
public static java.lang.String getRoot(java.lang.String path)
path
- The path used to get a root
public static java.lang.String[] getWildCardMatches(java.lang.String s, boolean sort)
s
- Wilcardssort
- Set to true will sort file names
s
in current directory.public static java.lang.String[] getWildCardMatches(java.lang.String path, java.lang.String s, boolean sort)
path
- The path were to searchs
- Wilcardssort
- Set to true will sort file names
s
in current directory.public static boolean match(java.lang.String pattern, java.lang.String string)
pattern
- The pattern used for comparisonstring
- The String to be checked
string
matches pattern
public static void sortStrings(java.lang.String[] strings)
public static java.io.File[] listFiles(java.lang.String[] names, boolean construct)
names
- Names of the filesconstruct
- Set it to true if names does not contain full paths
public static java.io.File[] listFiles(java.lang.String[] names, java.lang.String path, boolean construct)
names
- Names of the filespath
- Base path for filesconstruct
- Set it to true if names does not contain full paths
public static java.lang.String globToRE(java.lang.String glob)
glob
- Globbed filter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |