/* 3magic Coffee Table Tutorial 2 Tutorial2.java - Customizing the GridPanel display properties. © 1997-1999 3magic. All rights reserved worldwide. */ import java.awt.*; import java.applet.*; import CoffeeTable.Grid.*; public class Tutorial2 extends Applet { public void init() { // Instantiate a new Grid Panel with 10 rows and 5 columns // and other defaults like cell selection, row and column headers, // row and column lines enabled and with scrollbars. int numRows = 10; int numCols = 5; GridPanel grid = new GridPanel(numRows, numCols); // Be sure to set the preferred size if you are using it in a // layout that resizes based on preferred size. grid.setSize(400, 200); // Let's use Times, plain, 9-point. grid.setGridFont(new Font("TimesRoman", Font.PLAIN, 9)); // Set the text color to blue. grid.setGridTextColor(Color.blue); // Set the background color to light yellow. grid.setGridBackground(new Color(255, 255, 200)); // Set the flags for center justification and automatic string truncation. grid.setGridJustification(GridPanel.JUST_CENTER | GridPanel.TRUNC_STRING); // Set the grid lines to red. grid.setLineColor(Color.red); // Add the 3-D Border effect. grid.setThreeDBorder(true); // Make the column font into Helvetica. grid.setHeaderFont(new Font("Helvetica", Font.BOLD, 10)); // Make the column headers bigger. grid.setColHeaderHeight(25); // Show the row headers (defaults to no row headers). grid.setRowHeaderWidth(30); // Turn on automatic row numbering. grid.setRowNumbers(true); // Set the first three column widths to 70 pixels. grid.setColWidth(1, 70, true, true); grid.setColWidth(2, 70, true, true); grid.setColWidth(3, 70, true, true); // Add the grid into the applet panel add(grid); // Add some data for display. for (int col=1; col<=numCols; col++) { grid.setColHeaderText(col, "Column " + col, true); for (int row=1; row<=numRows; row++) { grid.setCellText(col, row, col + ", " + row, true); } } } }