Sample: Using Swing 1.0.2 JTable

Objective
This sample shows the use of the database support in Swing 1.0.2 using the JTable class and associated classes.

Time Required
Allow half an hour to run this sample.

Before You Begin
To run this sample you need to have the following tools installed and configured for your machine.

Description
This sample retrieves information from a DB2 database and displays it in a window created with JTable.

Running the sample
Open the IBM Domino Examples project and expand the com.ibm.ivj.examples.domino.jtable package.   To run this example on your machine you need to make a few small changes.  In the Workbench, select the EmplTable class.  The source code of this class will appear in the source window.  Change the following statements to your own machine variables:

  1. static String uid = "userid";  where "userid" is the userid that you use to connect to DB2
  2. static String pwd = "PASSWORD";  where "PASSWORD" is the password that you use to connect to DB2

Select your Parameters
Because this sample runs as both an application and an applet you can add the properties for both.

From the Properties for JTableExample notebook:

  1. Select the Applet tab to set the properties for the applet
  2. In the Width text field enter 450.
  3. In the Height text field enter 200.
  4. In the Parameters text field enter
    <param name=FirstName value=DANIEL>
    <param name=LastName value=SMITH>
  5. Select the Program tab to set the properties for the application.
  6. In the Command line arguments text field enter DANIEL SMITH
  7. Click OK.

Valid names for the parameters are any names in the DB2 SAMPLES database.

Run as an Applet

  1. Select the JTableExample class in the Workbench with mouse button 2.
  2. Select Run - In Applet Viewer.  The Applet viewer will open with the information for Daniel Smith.

Run as an Application

  1. Select the JTableExample class in the Workbench with mouse button 2.
  2. Select Run - Run main.  The application will open with the information for Daniel Smith.