Appendix C
Porting JClass 3.6.x Applications
Overview of Changes Porting Strategies Highlights of Main Changes
JClass LiveTable for Java2 is significantly different from previous versions. The focus of JClass LiveTable for Java2 is to make any changes necessary to take full advantage of Swing, and to restructure the product for future expansion.
C.1 Overview of Changes
The major changes are listed in the following table. Each change is discussed in more detail later in this appendix.
C.2 Porting Strategies
LiveTable 4.x comes with two tools designed to help you move from LiveTable 3.x to 4.x:
- com/klg/jclass/util/scripts/table3to4.pl is a Perl conversion script. It is designed to convert about 60-80% of table code.
com.klg.
jclass.table.Table
is a subclass ofJCTable
that supports the old LiveTable 3 API.
C.3 Highlights of Main Changes
New Beans Subpackage
All the Beans have been moved to the
beans
subpackage. There have been many Bean property changes.No More JCString
JCStrings
have been replaced by HTML in cells. This is supported by Swing, and has been added to LiveTable where appropriate.You can now put raw HTML into headers and footers, as long as the text starts with
<html>
. HTML is also valid in axis annotations, axis titles, and legend elements.Style-based Property Setting
Styles are objects that encapsulate all the visual attributes of cells. You set the property for the style object, then apply it to a range of cells.
In LiveTable 3.*, each visual attribute was set individually on a range of cells.
For example, the following code sets the foreground and background color on a range of cells:
table.setForeground(1, JCTableEnum.ALL, Color.blue);
table.setBackground(1, JCTableEnum.ALL, Color.black);Using styles, the attribute is set on the style, and the style is applied to the cells:
JCCellStyle style;
style.setForeground(Color.blue);
style.setBackground(Color.blue);
table.setCellStyle(1, JCTableEnum.ALL, style);In general, styles are easier to use for tables that tend to set multiple attributes on ranges of cells (the majority of cases for table users).
Please refer to Building a Table, in Chapter 2, for details on style-based property setting.
JCTable and Table
In LiveTable 4.x,
JCTable
is the core class.Table
is a subclass ofJCTable
that is to be used if you want to use LiveTable 3.x API calls.Table
does not support all the LiveTable 3.x API.Beans APIs
Many of the Bean properties are the same. The
Appearance
property has been replaced byStyles
.New events
The new event structure has been rationalized, and is documented in Events and Listeners, in Chapter 7. It is recommended that you rewrite your event handling code based on the new events.
Cell Editors and Renderers
Most classes now begin with
JC
.The drawing-based rendering model (formerly called
CellRenderer
) is now calledJCLightCellRenderer
. ThegetPreferredSize()
method now takes a Graphics object:There is now a new rendering model based on a component called
JCComponentCellRenderer
. Some of the default renderers now use this component instead ofJCLightCellRenderer
.
JCComponentCellRenderer
andJCLightCellRenderer
have a common base class calledJCCellRenderer
.Not all of the renderers are still around.
The advanced cell editors and renderers have been removed. Users are expected to use JClass Field for this purpose.