Java Reference
In-Depth Information
}
The
parseTable()
method has been modified slightly and now returns a vector of Strings. This
change supports the ability to issue several
SQL INSERT
commands as a result of a one-button click.
An additional change has been made to the
TableChangeListener
, which now accesses the
DatabaseUtilities
class directly rather than through the event system. Again, this has been done
to support the ability to issue several SQL commands in response to a button click.
The Controller Class
The
DatabaseManager
class is shown in
Listing 6-6
.
It is based on the class used in
Chapter 5
.
It
incorporates additional code to hook in the new menu and a new method,
displayTableEditFrame()
, to display the new
JInternalFrame, TableEditFrame.
Listing 6-6: DatabaseManager — Controller class
package jdbc_bible.part2;
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;
import javax.swing.*;
import javax.swing.event.*;
public class DBManager extends JFrame{
JMenuBar menuBar = new JMenuBar();
JDesktopPane desktop = new JDesktopPane();
String database = null;
String tableName = null;
String menuSelection = null;
TableBuilderFrame tableMaker = null;
TableEditFrame tableEditor = null; // added for Chapter 6
DatabaseUtilities dbUtils = null;
TableMenu tableMenu = new TableMenu();
EditMenu editMenu = new EditMenu(); // added for Chapter 6