acm.util
Class JTFTools

java.lang.Object
  |
  +--acm.util.JTFTools

public class JTFTools extends Object

This class provides a small collection of static utility methods that are used elsewhere in the ACM packages.


Constructor Summary
JTFTools()
           
 
Method Summary
Container createEmptyContainer()
Returns an empty lightweight container.
Color decodeColor(String name)
Decodes a color name.
Font decodeFont(String str)
Decodes a font in the style of Font.decode.
Font decodeFont(String str, Font oldFont)
Decodes a font in the style of Font.decode.
Applet getApplet()
Returns the current applet.
Frame getEnclosingFrame(Component comp)
Returns the frame that encloses the specified component.
Font getStandardFont(Font font)
Returns a font that will approximate the specified font in this environment.
boolean isAnonymous(Thread t)
Returns true if the supplied thread is an anonymous one created automatically by the system.
void pause(double milliseconds)
Delays the calling thread for the specified time, which is expressed in milliseconds.
void registerApplet(Applet applet)
Adds this applet to a table indexed by the current thread.
void registerApplet(Applet applet, Thread thread)
Adds this applet to a table indexed by the specified thread.
void terminateAppletThreads(Applet applet)
Terminates all of the threads that are registered as belonging to the specified applet.
 

Constructor Detail

public JTFTools()

Method Detail

public static Container createEmptyContainer()

Returns an empty lightweight container. Several packages need to create such components as placeholders. Defining it in JTFTools gives those pacakges access to a common mechanism.

 
Usage: Container comp = JTFTools.createEmptyContainer(); 
Returns: An empty lightweight container that can be used as a placeholder
 

public static Color decodeColor(String name)

Decodes a color name. This method is similar to Color.decode except in that it allows named colors and system colors.

 
Usage: color = JTFTools.decodeColor(name); 
Parameter: 
name  The string name of the color
Returns: The color corresponding to the specified name
 

public static Font decodeFont(String str)

Decodes a font in the style of Font.decode. This version of the method is included to centralize font operations and is functionally identical to Font.decode.

 
Usage: Font font = JTFTools.decodeFont(str); 
Parameter: 
str  The string to decode
Returns: The new font
 

public static Font decodeFont(String str, Font oldFont)

Decodes a font in the style of Font.decode. The only difference is that this method takes a font parameter that gives default values for the different parts of the font. If the family, size, or style is specified as an asterisk, the corresponding value is taken from the supplied font.

 
Usage: Font font = JTFTools.decodeFont(str, oldFont); 
Parameters: 
str  The string to decode
oldFont  The font whose properties are used as defaults
Returns: The new font
 

public static Applet getApplet()

Returns the current applet. This implementation may fail in multithreaded programs. Such programs should therefore not rely on this facility. It is appropriate to use this facility, for example, during the init method of a program, which is the only context in which it is applied in the JTF tools.

 
Usage: Applet applet JTFTools.getApplet(); 
Returns: The currently running applet
 

public static Frame getEnclosingFrame(Component comp)

Returns the frame that encloses the specified component.

 
Usage: Frame frame = JTFTools.getEnclosingFrame(comp); 
Parameter: 
comp  The component at which to start the search
Returns: The nearest enclosing Frame object
 

public static Font getStandardFont(Font font)

Returns a font that will approximate the specified font in this environment. This method is required because some browsers do not support the standard fonts Serif, SansSerif, and Monospaced.

 
Usage: Font newFont = JTFTools.getStandardFont(font); 
Parameter: 
font  The font being checked
Returns: The new font
 

public static boolean isAnonymous(Thread t)

Returns true if the supplied thread is an anonymous one created automatically by the system.

 
Usage: if (JTFTools.isAnonymous(t)) . . . 
Parameter: 
 The thread being tested
 

public static void pause(double milliseconds)

Delays the calling thread for the specified time, which is expressed in milliseconds. Unlike Thread.sleep, this method never throws an exception.

 
Usage: JTFTools.pause(milliseconds); 
Parameter: 
milliseconds  The sleep time in milliseconds
 

public static void registerApplet(Applet applet)

Adds this applet to a table indexed by the current thread.

 
Usage: JTFTools.registerApplet(applet); 
Parameter: 
applet  The applet being registered
 

public static void registerApplet(Applet applet, Thread thread)

Adds this applet to a table indexed by the specified thread.

 
Usage: JTFTools.registerApplet(applet); 
Parameters: 
applet  The applet being registered
thread  The thread used as the key
 

public static void terminateAppletThreads(Applet applet)

Terminates all of the threads that are registered as belonging to the specified applet.

 
Usage: JTFTools.terminateAppletThreads(applet); 
Parameter: 
applet  The applet whose threads are being terminated