JClass Elements

PreviousNextIndex

17

Introduction to the Utility Classes

Utilities 



17.1 Utilities

JClass Elements's utilities live for the most part in two packages: com.klg.jclass.util, and com.klg.jclass.util.swing. Some components, like JCTreeTable, rely on support classes found in a util subpackage, in this case in com.klg.jclass.util.treetable, and JCDateChooser has a package of its own, com.klg.jclass.util.calendar.

Here is a brief description of the utility classes:

Name of Utility

Description

JCDebug

Place debug statements in your Java code that contain an optional level indication. Use a print level setting to control the detail in your debugging printout. A PERL script lets you remove all debug statements when your code is ready for release.

JCIconCreator

There are times when you would like to have a custom image as part of your toolbars, labels, buttons, and so on, yet you don't want to go to the trouble of using a paint package. JCIconCreator lets you use String arrays to create image icons. The format is similar to that used in XPixMap (XPM) format files.

JCEncode
  Component

You can encode the image information for any component in your application with this utility. Since all the children of the chosen component are also encoded, you can capture a picture of your entire user interface for any well-behaved component hierarchy, or any single one of its child components. The utility encodes images in the public-domain Portable Network Graphics (PNG) format.

 

Note: If you wish to export your images in GIF format, you'll need a license from the copyright holder, Unisys Corp. Quest Software will send you the GIF encoder class upon receipt of a copy of your license from Unisys.

 

You need JClass PageLayout to encode components in EPS, PS, PDF, or PCL. JClass PageLayout is available as a part of the JClass DesktopViews suite.

JCListenerList

JCListenerList is a class that assists with keeping track of event listeners in a thread-safe manner.

JCMappingSort

Sorting can be accomplished by indexing the list of objects that are going to be ordered according to some comparison policy. It can be much more efficient to sort these indices instead of sorting the objects themselves. The idea is to form an array of indices. The utility is documented with JCSortableTable.

JCProgress
  Helper

JCProgressHelper is a class that lets you create and manage a thread-safe progress dialog. With it, you can monitor a potentially time-consuming operation and present a visual record of its progress. If it the operation will take more than a specified time, a progress dialog will be popped up.

JCString
  Tokenizer

JCStringTokenizer provides simple linear tokenization of a String. The set of delimiters, which defaults to common whitespace characters, can be specified either during creation or on a per-token basis. It is similar to java.util.StringTokenizer, but delimiters can be included as literals by preceding them with a backslash character (the default). It also fixes a known problem: if one delimiter immediately follows another, a null String is returned as the token instead of being skipped over.

JCSwing

  Utilities

This class currently contains a single method: setEnabled(), which takes a Component and a Boolean as parameters. It uses the Boolean parameter to enable or disable all the children of the component, which are themselves Components.

Thread Safety

The JCSwingRunnable class helps you manage your threads by providing a class that you can subclass easily. It provides methods that simplify handling execution in the proper threads.

JCTreeSet

This class adds to Swing's functionality by providing you with a way of representing the elements of a set as a binary-sorted tree. If the elements of the set have an defined ordering principle, it is used by default to construct the B-tree, but other ordering mechanisms are possible.

JCTypeConverter and

JCSwingType
  Converter

You frequently need to convert objects to Strings, and Strings to objects, when you are coding a user interface. For example, a user types a String as input that you would like to convert to an object. The input String might consist of a sequence of integers, delimited by commas, that you would like to convert to an array. There are also times when you need to convert an object to a String so that you can place the text on a label or a button. The JClass type converters are a collection of the most useful conversions from String to object, and from object to String. The static methods of JCTypeConverter let you retrieve parameters from an application or applet, and convert these parameters to particular data types.

JCWordWrap

JCWordWrap provides a static method called wrapText that performs basic word-wrap logic on a String, given a line width and new line delimiter.


PreviousNextIndex