TOC PREV NEXT INDEX



Create a better database interface


What if you want to see multiple rows of data at the same time? The next section of the tutorial will show you how to do this.

First, we will add new elements to your existing layout.

  1. To display the properties of the border layout in our application, right click on one of the JTextFields. A pop-up menu will appear, showing the reverse containment hierarchy of the component that you right clicked on. (In other words, this is a quick way to see the properties of a component, its parent layout, its parent's parent layout, etc..)
  2. Select 'border1' from the popup menu. This will display the properties of the border layout.
  3. Click "Show empty panels" checkbox to make the unused empty spaces reappear in it.

We are going use Swing's JList and JTable to display multiple rows of data simultaneously. The Swing components, by themselves, do not have scrollbars. We will use JScrollPanes to provide scrollbars.

  1. From the Swing page of the palette, select 'ScrollPane' (JScrollPane).
  2. Click once in the 'West' and again in the 'Center' of the border layout.
  3. From the Swing page of the palette, select 'List' (JList).
  4. Click once in the 'Viewport' of the JScrollPane that you just placed in the west to add a list.
  5. Change the list's Object name to "listOfDescriptions".
  6. Change the list's Prototype Value for Sizing to be "This is the width that we want"
  7. From the Swing page of the palette, select 'Table' (JTable).
  8. Click once in the 'Viewport' of the JScrollPane that you just placed in the center of the border layout to add a table.
  9. Change the table's Object name to "bigTable".
  10. Change the table's Selection type to be "Row selection".
  11. Choose "Hide all empty panels" from the parts menu to hide the empty parts of the border layout.

Now the layout has been improved, and we are ready to make these new components work with the database.


Data Representations, Inc.
http://www.datarepresentations.com
support@datarepresentations.com
sales@datarepresentations.com
TOC PREV NEXT INDEX