Java GUIs
Now that we’ve looked at the basics of the JDBC API, let’s do something interesting with GUI clients. Our goal is to figure out how Java works at this level, as well as to provide an example along the lines of the Wosql and OraExplain programs (see the discussion of Tcl/Tk and Perl/Tk, respectively, in Chapter 3). Most of the open source Java projects described in Chapter 8, also involve GUIs, so it will be helpful to look at how you can use Java to build such applications. First we’ll build a basic GUI, and then we’ll blend some JDBC into it so we will be able to connect to an Oracle database.
Java Swing
The quickest way to get going with a Java GUI is to use the Java Swing library. Java Swing is an extension of AWT, and these two GUI toolkits are intimately related:
- AWT
AWT, the original Abstract Windowing Toolkit, comes with the standard JDK distribution. It handles simple graphics, widgets, and layout managers for different native formats.
- Swing
Although it relies on AWT, Swing is entirely Java-based and covers a far more generalized and flexible set of GUI capabilities through its Java Foundation Classes (JFC). It used to come in a separate package from Java Version 1, but it’s now entirely integrated within the Java2-based JDKs.
The main web site for Java Swing is the Swing Connection, where you can find out about Swing and all of its many component GUI widgets:
http://java.sun.com/products/jfc/tsc/index.html |
There are also many GUI builders available to help create ...
Get Oracle and Open Source now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.