![]() ![]() ![]() |
Appendix C
Porting JClass 3.6.x Applications
Key Concept Differences
Code Differences
Property Changes
Porting Guidelines
Event Handling Changes
There have been significant structural changes to JClass Field beginning in its 4.x version. These modifications allow more flexibility and control over the composition of fields. Although the changes are noteworthy, you can easily convert any code created with 3.6.x versions to version 4.x and higher. The following sections will describe how to upgrade your code to JClass Field 4.5 and higher.
C.1 Key Concept Differences
In earlier versions of JClass Field, each field consisted of a visual component and a validator together. The validator portion determined what type of data the field expected. The names of the fields indicated their visual aspect and supported data type. For example, a text field that contained integers and a text field that held String values were named
JCIntTextField
andJCStringTextField
respectively.Now the five basic styles of visual components, which are represented by one of JClass Field's standard Beans:
JCTextField
,JCSpinField
,JCComboField
,JCPopupField
, andJCLabelField
, are separated from the validators and the supported data types. To use a field, you must associate it with a validator and declare an appropriate value model. The following table lists the a few examples of the combination of components, validators, and value models in JClass Field 4.x that are equivalent to fields in earlier versions:You can duplicate all the fields contained in earlier versions by selecting the corresponding field, validator, and value model. In fact, you can create even more fields since JClass Field 4.x and higher expands the list of supported validators to include
java.lang.byte
,java.lang.short
,java.lang.long
,java.lang.float
,java.math.BigDecimal
,java.sql.date
, andjava.sql.timestamp
, and introduces a new GUI component,JCLabelField
. This new field can be used to simulate a heading or to display uneditable data.
C.2 Code Differences
The following table shows the differences in code between JClass Field 4.x and higher, and previous versions for a text field containing a String value.
C.2.1 Converting Your Code
This section breaks down the above code listings and gives a line-by-line description of the differences.
C.3 Property Changes
Since the introduction of the
validator
andinvalidInfo
objects, the properties have been divided between these two objects and the field component, which in earlier versions contained all the properties. The following table shows how the JClass Field 4.x and higher properties are allocated.
C.4 Porting Guidelines
The following list gives a general outline of the steps you should follow to port your code to JClass Field 4.x and higher from earlier versions.
- Determine the field, value model, and validator that correspond to your existing field. Create each of these objects and associate the value model and validator with the field.
- Separate any JClass Field properties you use into field component, validator and invalid properties.
- If you have any invalid properties, declare the field's
invalidInfo
object and set the properties using the newinvalidInfo
.- Set any other properties using the field component or validator objects.
C.5 Event Handling Changes
JClass Field events have also undergone significant change in version 4.x and higher.
The event listener that receives the events generated by the four editable Fields is now called
JCValueListener
instead ofJCFieldListener
. Its methods arevalueChanging()
andvalueChanged()
instead ofvalueChangedBegin()
,valueChangedEnd()
, andstateIsInvalid
.Changes to any one of the Fields are handled by invoking
addValueListener()
. You supply the code to implement theJCValueListener
interface. To register the method see addValueListener, removeValueListener, in Chapter 2.The methods of the JClass Field event listeners are compared below:
Although the
stateIsInvalid()
method is not available inJCValueListener
, you can use a Field component'saddPropertyChangeListener()
method to determine changes to the state of a field.
![]() ![]() ![]() |