Virtual Machinery logo SORTable - Manual
Home Sort Table Manual Demo Other Products
Using the SORTable Classes

Quick Start for Visualage

Once you have installed the product (see installation guide here) create a new project and package and make sure that the Virtual Machinery Sorted Table project is visible.

How the SORTable classes work - building a sorted table with 'double-click' sorting

How the SORTable classes work - building a sorted table with associated sort button

How the SORTable classes work - modifying the presentation of a sorted table

The code below (which is inserted in the main method) illustrates how the appearance of the table can be modified. In this case we are striping the columns painting each alternate one yellow. We are also altering the size of the third column and applying right alignment to the fifth column -


	/**** Start of code to change the table to show alternate colours on each column ****/
	javax.swing.JTable theTable = aVMTableDemo.sortTable.getScrollPaneTable();
	javax.swing.table.DefaultTableCellRenderer aRenderer = new javax.swing.table.DefaultTableCellRenderer();
	aRenderer.setBackground(java.awt.Color.yellow);
	theTable.getColumnModel().getColumn(3).setPreferredWidth(20);
	int i = 0;
	while ( i < theTable.getColumnModel().getColumnCount()) {
		if (i==4) {
			javax.swing.table.DefaultTableCellRenderer rend2 = new javax.swing.table.DefaultTableCellRenderer();
			rend2.setBackground(java.awt.Color.yellow);
			rend2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
			theTable.getColumnModel().getColumn(i).setCellRenderer(rend2);
		}
		else {theTable.getColumnModel().getColumn(i).setCellRenderer(aRenderer);}
		i+=2;
	}
	/**** End of code to change the table to show alternate colours on each column ****/
		
	frame.show();

The table should look something like this -



SORTable Demo - striped columns