/* 3magic Coffee Table Tutorial 14 Tutorial14.java - More Multiline Text. © 1997-1999 3magic. All rights reserved worldwide. */ import java.awt.*; import java.applet.*; import java.util.*; import java.lang.Math; import CoffeeTable.Grid.*; public class Tutorial14 extends Applet { // Labels for columns. String quarters[] = {"Spring", "Summer", "Fall", "Winter"}; // Countries int fNumCountries = 39; String country[] = { "Andorra", "Afghanistan", "Antigua", "Anguilla", "Albania", "Armenia", "Angola", "Antarctica", "Argentina", "American Samoa", "Austria", "Australia", "Aruba", "Azerbaidjan", "Bosnia-Herzegovina", "Barbados", "Bangladesh", "Belgium", "Burkina Faso", "Bulgaria", "Bahrain", "Burundi", "Benin", "Bermuda", "Brunei", "Bolivia", "Brazil", "Bahamas", "Bhutan", "Bouvet Island", "Botswana", "Belarus", "Belize", "Canada", "Chile", "Congo", "Cameroon", "China", "Colombia" }; // Our grid. GridPanel fGrid; // Rows and Columns; int fNumRows = fNumCountries; int fNumCols = 100; // Some Buttons. int fNumButtons = 5; Button fButton[] = new Button[fNumButtons]; String buttonLabels[] = { "Clear Data", "Reload Data", "8 x 8", "100 x 24", "Squish Columns"}; /** * Initialize. */ public void init() { // Instantiate a new Grid Panel with // defaults like cell selection, row and column headers, // row and column lines enabled and with scrollbars. fGrid = new GridPanel(fNumRows, fNumCols); // Be sure to set the preferred size if you are using it in a // layout that resizes based on preferred size. fGrid.resize(400, 200); // Set up the row/col dimensions. fGrid.setRowHeight(50); fGrid.setColHeaderHeight(40); fGrid.setRowHeaderWidth(100); // Let's use Times, plain, 9-point. fGrid.setGridFont(new Font("TimesRoman", Font.PLAIN, 9)); // Set the background color. fGrid.setGridBackground(new Color(230, 255, 230)); // light green. fGrid.setHeaderBackground(new Color(230, 230, 255)); // light blue. // CONFIGURE WORD_WRAP ------------------------------------------ // Multiline text. GridAttributes ga = fGrid.getGridAttributes(); ga.setJustification(ga.getJustification() | GridPanel.WORD_WRAP); // Multiline column headers. ga = fGrid.getColHeaderAttributes(); ga.setJustification(GridPanel.JUST_CENTER | GridPanel.WORD_WRAP); // Add some data for display. this.loadData(); // Add the grid into the applet panel add(fGrid); // Add some control buttons. for (int i = 0; i