2
|
1 |
The four examples in this directory show how to use some of the
|
|
2 |
features of the JTable component.
|
|
3 |
|
|
4 |
TableExample:
|
|
5 |
This application includes a GUI for configuring the
|
|
6 |
database connection and specifying the query.
|
|
7 |
TableExample2:
|
|
8 |
The query and database connection are specified at the command
|
|
9 |
line. The results are displayed in a JTable.
|
|
10 |
TableExample3:
|
|
11 |
Is a minimal example showing how to plug a generic sorter into the
|
|
12 |
JTable.
|
|
13 |
TableExample4:
|
|
14 |
Uses specialized renderers and editors.
|
|
15 |
|
|
16 |
TableExample3 and TableExample4 do not depend on database connectivity
|
|
17 |
and can be compiled and run in the normal way.
|
|
18 |
|
|
19 |
The most interesting example is probably TableExample, which has a
|
|
20 |
TextArea that can be used as an editor for an SQL expression. Pressing
|
|
21 |
the Fetch button sends the expression to the database. The results are
|
|
22 |
displayed in the JTable underneath the text area.
|
|
23 |
|
|
24 |
To run TableExample and TableExample2, you need to find a driver for
|
|
25 |
your database and set the environment variable JDBCHOME to a directory
|
|
26 |
where the driver is installed. See the following URL for a list of
|
|
27 |
JDBC drivers provided by third party vendors:
|
|
28 |
|
|
29 |
http://java.sun.com/products/jdbc/drivers.html
|
|
30 |
|
|
31 |
Once you find the driver, you can run one of the database examples by
|
|
32 |
specifying a class path that includes the JDBC classes and the example
|
|
33 |
classes.
|
|
34 |
|
|
35 |
For example:
|
|
36 |
|
|
37 |
java -classpath $(JDBCHOME):TableExample.jar TableExample
|
|
38 |
|
|
39 |
These instructions assume that this installation's version of the java
|
|
40 |
command is in your path. If it isn't, then you should either
|
|
41 |
specify the complete path to the java command or update your
|
|
42 |
PATH environment variable as described in the installation
|
|
43 |
instructions for the Java(TM) SE Development Kit.
|
|
44 |
|