Appendix G
Overview of Examples and Demos
G.1
JClass LiveTable Examples
The following sections offer an overview of the examples included with JClass LiveTable. These examples demonstrate the various concepts that can be used to create a table. The examples vary in depth and complexity, but all are helpful in showing you how to implement some of JClass LiveTable's features.
Note: Please consult the Installation Guide to ensure that you are properly set up to run these examples.
G.1.1
Introductory Examples
The introductory JClass LiveTable examples are part of the tutorial found in `Hello Table' - JClass LiveTable Tutorial, in Chapter 1, that walk you through the construction and modification of a basic table. These examples are part of the examples.table.intro
package, and are found in the examples/table/intro directory:
ExampleTable1.java
|
A table with basic visual and interactive properties.
|
ExampleTable2.java
|
A table based on the previous example, but with labels.
|
ExampleTable3.java
|
The previous example table's label colors have been changed.
|
ExampleTable4.java
|
The label fonts and text alignment have been modified.
|
ExampleTable5.java
|
Cell and frame borders and spacing have been changed. One table cell's colors have been changed.
|
ExampleTable6.java
|
Cell editing has been enabled. Cell width and height have been changed.
|
ExampleTable7.java
|
Table resizing only with labels has been set.
|
ExampleTable8.java
|
Column sorting has been enabled.
|
G.1.2
Table Layout Examples
The layout examples demonstrate how to build tables that go beyond the basic grid design for tables. These are part of the examples.table.layout
package, and are found in the examples/table/layout directory:
Cars.java
|
A table that contains tables. This example also demonstrates cell spanning and visual property settings.
|
Flexible.java
|
Columns resize dynamically, depending on how the whole table is resized.
|
G.1.3
Cell Style Examples
The cell style examples demonstrate how style properties affect the appearance of individual or groups of cells. You can find more information about cell style properties in Cell Styles, in Chapter 2. These examples are part of the examples.table.styles
package, and are found in the examples/table/styles directory:
Animated.java
|
Displays animated cells.
|
BorderTypes.java
|
Showcases the cell border options available, including some customized cell borders.
|
CellBorders.java
|
Demonstrates various cell border appearance attributes, including border type, border width, and cell side coverage. The table updates with each selection.
|
RepeatColor.java
|
Uses alternating background colors for rows or columns, to improve readability.
|
TextureTable.java
|
Uses a customized border type that tiles a background image onto table cells.
|
UpdateStyle.java
|
Continuously updates the background color property for a particular table row's style.
|
G.1.4
Cell Examples
The cell editing and rendering examples demonstrate specific applications for JClass LiveTable's editors and renderers. For more information about cell editors and renderers, please refer to Displaying and Editing Cells, in Chapter 4. These examples are part of the examples.table.cell
package, and are found in the examples/table/cell directory:
CurrencyTable.java
|
Uses CurrencyRenderer to take all data, regardless of its original type, and render it as dollar values in the table.
|
Histogram.java
|
Uses a custom cell renderer to take randomized integer data, and render them as horizontal bars in a table.
|
MoneyTable.java
|
Uses a custom cell editor and a custom data type.
|
TriangleTable.java
|
A demonstration of a non-text based editor and renderer for Integer and Polygon types.
|
WordWrap.java
|
Uses a word wrapping renderer to handle long String data in cells.
|
G.1.5
Table Listener Examples
The event and listener examples demonstrate how you can work with events that your table receives. For more information about the types of events and listeners available, please refer to Events and Listeners, in Chapter 7. These examples are part of the examples.table.listeners
package, and are found in the examples/table/listeners directory:
BooleanDisplay.java
|
Uses the JCCellDisplay listener to intercept the display event and change it before rendering (changes the boolean from true /false to yes /no ).
|
CancelEdit.java
|
Shows how to use JCTableDataEdit and JCTableDataListener to cancel active edits when the data source changes.
|
DoubleClickEdit.java
|
Demonstrates the use of JCEditCell events by requiring a user to double click a cell in order to edit it. A single click, or click and drag, only selects cells.
|
EditCell.java
|
Demonstrates the use of JCEditCell events by placing a message in the table's pane, telling you which column's cell is being edited.
|
ResizeCell.java
|
Uses JCResizeCell events to ensure that the maximum and minimum set values for row heights and column widths are adhered to when the user resizes rows and columns. These maximum and minimum values are defined in the table's code.
|
SelectListener.java
|
Uses JCSelectListener events to make sure that the portion of the table that is defined as non-selectable are not included in cell range selections, and cannot be initially selected.
|
SkipNavigation.java
|
Cell traversal events are used to listen for and skip a column. When the user traverses to the right from column 0, cell focus skips column 1 and moves to column 2.
|
Sorter.java
|
Demonstrates column sorting by performing a String and numerical sort on a column of integers.
|
TwoTables.java
|
JCScroll events are used to sync the horizontal scrolling for two separate tables.
|
G.1.6
Table Interaction Examples
The interaction examples show you how to improve the usability of your table applications by enhancing some of your table's interactive features. For information about table interactions, please refer to Programming User Interactivity, in Chapter 6. These examples are part of the examples.table.interactions
package, and are found in the examples/table/interactions directory:
ColumnLabelPopUp.java
|
Shows how to use column labels as tool tips.
|
DragDrop.java
|
Demonstrates the use of drag and drop by allowing the user to interactively reorder rows and columns. This is done by clicking and dragging labels.
|
ExcelTableExample.java
|
Demonstrates how to copy and paste selected cells from a JCTable to a Microsoft Excel spreadsheet and vice-versa.
|
TableAutoColumnResize.java
|
Depicts how to emulate JTable auto column resizing in JCTable .
|
TraverseOnEnter.java
|
Displays how cell traversal (across rows) can optionally be handled by using the Enter key.
|
G.1.7
Data Source Examples
The data source examples demonstrate how you can customize and use data sources with your table application. These examples are part of the examples.table.datasource
package, and are found in the examples/table/datasource directory:
DynamicTest.java
|
This example table continually updates the data it displays, as its data source's values randomly change.
|
DynamicTest2.java
|
This example is the same as DynamicTest.java, except that it uses AbstractDataSource .
|
FileData.java
|
Demonstrates how to load data from an external file by using JCFileDataSource . Both a CSV and table format file are loaded and displayed side by side.
|
FontList.java
|
Uses the getFont() method to access AWT's available fonts and use it as the data source. Displays the name, appearance, and other information pertaining to the available fonts.
|
Pivot.java
|
Shows how to create a data source instance that can transpose itself. You can use a customized data source or create your own.
|
StaticEditableTest.java
|
A basic, custom data source that is built on editable String values.
|
StaticTest.java
|
This example is the same as the previous example, except that the table data is not editable.
|
XMLFileData.java
|
Demonstrates how to load XML-formatted data from an external file by using JCFileDataSource .
Please note that in order to run this example, you will need to have the jaxp.jar and crimson.jar files in your CLASSPATH. For more information, please see Loading Data from an XML Source, in Chapter 3.
|
XMLTableModelData.java
|
Demonstrates how to load XML-formatted data into a Swing TableModel class.
Please note that in order to run this example, you will need to have the jaxp.jar and crimson.jar files in your CLASSPATH. For more information, please see Loading Data from an XML Source, in Chapter 3.
|
G.1.8
DataSource Data Binding Examples
The data binding examples demonstrate the use of data binding in tables. Binding your table to a ODBC, JDBC, or IDE-specific data source gives you live control over a robust data source. These examples are part of the examples.table.db.*
package, and are based in the examples/table/db/ directory:
datasource/SimpleData.java
|
Shows how to bind DSdbTable to JClass DataSource.
|
jbuilder/JBuilderDBTable.java
|
This example shows how to bind JBdbTable to a JBuilder QueryDataSet.
|
G.1.9
Advanced JClass LiveTable Examples
The advanced examples combine two or more concepts demonstrated in previous examples. They are found in the examples.table.advanced
package, and are in the examples/table/advanced directory:
DecimalTableCellDisplay.java
|
This example assigns each column to take on a different format of the same number. It uses CellDisplayListener to format the rendered text, and it uses UserData to store the numeric format of the cells.
|
DecimalTableCellStyle.java
|
This example shows how to achieve the same results as DecimalTableCellDisplay.java, except that CellStyleModel object is used.
|
Gradient.java
|
Creates a color whose value is incrementally changed from cell to cell. This example uses the cell style defaults, but shows how to bypass some properties for particular cells.
|
G.2
JClass LiveTable Demos
The JClass LiveTable demos showcase different types of complete table solutions. They combine several table concepts that are explained in this manual, including cell spanning, user interaction, and editors and renderers.
The following table offers an overview of each demo that comes with JClass LiveTable, including demo name, package, description, and sample screen shot.
Note: Please consult the Installing JClass Products section in the Installation Guide to ensure that you are properly set up to run these demos.
BeanSweeper.java
demos.table.beanSweeper
This demo recreates the well known minesweeper game. In the creation of this table, cell styles are used extensively. Style properties that affect cell and border colors, border types, and image use, give the game its look.
|
Calculator.java
demos.table.calculator
This basic calculator demo is a simple yet effective demonstration of how cell styles can be used to customize the look of your table. In this case, cell border and color properties are set to make this look like an authentic $2 calculator. This demo also implements a data source that gathers information that is input by the user.
|
CustomCells.java
demos.table.customCells
An effective demonstration of using custom cell renderers, which take various data types and converts them to the standard desired formats. Also, column sorting and JClass Field component integration are showcased.
|
Matrix.java
demos.table.matrix
This information matrix shows how a custom JCCellRenderer can be used to add properties that are not built into JClass LiveTable. Here, an implementation of the CellStyleModel interface, RotatedCellStyle , adds the Rotation property to render text at any given angle.
|
PrimeTime.java
demos.table.primetime
This demo presents television listings, and shows what can be achieved with cell styles and cell spanning. This demo also incorporates printing functionality into a table.
|
SpreadSheet.java
demos.table.spreadsheet
This spreadsheet demo emulates an Excel-style spreadsheet. It supports a subset of spreadsheet functionality and is intended to demonstrate formulae integration with table.
Within this demo you can also chart a selected region of the spreadsheet.
|
Stocks.java
demos.table.stocks
This stock information demo provides the user with quick data updates and colors rows according to changes in value. Custom cell rendering and cell styles are emphasized with this demo.
|