JClass Elements - Data Display 

Java Swing provides many components for thick Java clients right out of the box. JClass Elements is a broad collection of GUI components and utility classes designed to augment Swing’s basic offering. These include components for showing data in sortable tables and tree controls.  



Tables are a common way to show data when there are multiple attributes that are relevant for how that data is arranged and displayed. For example, you might be looking at a table of stocks in your portfolio showing not only their current price, but also the price at which you bought the stock, as well as the yield on your investment and what you expect to make in annual dividends. Depending on your objective as an end user, you might wish to sort these stocks by any one of these attributes.


JCSortableTable is an extension of Swing’s JTable that allows you to use any of the columns in your table to sort the data as you would a spreadsheet. Internally, this component wraps any TableModel it is given with its own row-sorting model interface. This implementation allows you to change the order in which the columns are used for sorting by using an array of column indices and by changing the columns sort type from “ascending” to “descending.” Elements in the primary column that compare the same are arranged by sorting a secondary column. You can also set whether a table is re-sorted automatically when its data changes. End users may change the order and direction of the sort simply by clicking on the table’s column headers.


Cells within the table may also be set to be “editable,” and how they are rendered may be customized. Normally, you do not need to be concerned with the details of how table cells are rendered, because renderers for most common cases have already been supplied. On the other hand, you might decide to use a custom renderer of your own design. The component uses its own cell editor/renderer mechanism that allows cell rendering components to be handled uniformly instead of having to manage the renderer types one by one.


JCTreeExplorer and JCTreeTable 

A tree is another common mechanism for displaying related data (in this case, entities that are related by hierarchy). The most familiar interface of this type is a file system with a set of folders containing subfolders and documents, but trees can also be used to show network topology, organizational charts, or custom taxonomies. 


Not only are trees used to display data, but they also are used to manage the data. For instance, using a tree, you can move files around on file system or you can manipulate an organizational chart to change to whom an employee reports.


Data structures that can be displayed as trees often have table-like properties. A file system has a hierarchical organization that is well-suited to be represented as a tree. Yet the individual directories and files have properties such as name, size, type, and date modified. These properties would be well suited by a row-column organization.


JCTreeExplorer and JCTreeTable fill the need for components that have the dual characteristics of a tree and a table. These components are enhancements of Swing’s JTable and JTree. They allow you to view your data as a tree, and any tree node may have tabular data associated with it. JCTreeExplorer presents a table for the currently selected node, while JCTreeTable shows table rows for all visible nodes.


image2 (1)

An Example of JCTreeExplorer 



image1 (1)

An Example of JCTreeTable 


Your data source for a tree may be arbitrary so long as you implement the JCTreeTableModel interface. This interface allows clients to retrieve values from specific nodes and columns, retrieve or determine the number of children for a node, and add event listeners (like opening and closing of nodes). Furthermore, the folder icons can be customized by replacing the standard editor/renderer. You may, in fact, want to have two icons: one for nodes with children and one for leaf elements.


Likewise, the table contains a flexible “painter” object that accommodates a Swing cell renderer or a JClass cell renderer. As with the JCSortableTable component, these two components have advanced column sorting functionality. Each column can have a different ordered set of columns that are to be used as secondary sort keys. When a user clicks on a column header to sort that column, any identical cells are arranged based on the sort order of the secondary key, or keys.



Additional Components 

In addition to these data display controls, JCClass Elements provides for a variety of form input (see our previous post on this topic) as well UI layout controls for handling multiple documents, wizards and advanced layouts which we will discuss in a future post.



Request a Free JClass Elements Upgrade through Scout Solutions

For a limited time, Scout Solutions is offering a free upgrade to our new and improved JClass software for current Quest JClass customers. With the purchase of a new support agreement, you will receive access to our dedicated expert JClass Support team who can solve technical issues and answer questions. Save yourself the trouble of upgrading to a new software and upgrade your current version of JClass. Claim your free upgrade and get access to our new version of JClass!

Request your free upgrade