Build a Single Table Database

Build The Project

Build a project , but uncheck the "Use Only JDK & Swing Classes" check box . Check only the center of the screen checkbox for the Frame. Enter the design pane for the main frame and change the bevelPanel1 layout to BorderLayout. In the application wizzard frame dialog do not check any of the boxes except "Center frame on screen".



Next add a Navigation bar (NORTH) and status bar (SOUTH) from the dbSwing pallet. Set the border in the status bar to etched in the object inspector. Next set the maximum size, minimum size and preferred size (circled areas in diagram). Finally delete the text in the status bar.

Next add a TableScrollPane (CENTER) to the bevelPanel1 and add a jdbTable to the TableScrollPane (use the tree to make sure).

Next add a database component and QueryDataSet to your Data Access tree. Set the query to "SELECT * From myTable". Now you can connect your query to the jdbTable. Make sure to select JTable. AUTO_ RESIZE_ ALL_ COLUMNS from the autoresize mode property. You must import javax.swing.JTable to get this constant.

At this point you have a program that can modify the table by adding new items, deleting and editing existing items. When adding items leave the id blank since it is provided by the database (you might think of not including that column in the table). There is an update button and refresh button. After adding an item make sure to save then refresh to get the id number. After entering data in a field hit return before going to the next field with the tab or arrow key.

Complete Program

Click here to get the complete program.