By Tony Bevis on Tuesday, 24 October 2023
Category: Java

Java programming course: 18.1 Finishing off the User Interface

Finishing off the User Interface

This section puts the finishing touches to the graphical part of the application by creating a read-only table for the zoo's visitors, defining a menu-bar and toolbar, and by making the application adopt the running system's look-and-feel.

In this section you will learn:

A table of visitors

For simplicity, the list of visitors, as defined in ZooAdministrator, will be displayed in a read-only table in a tab of the AdministratorFrame. First, you need to do some preparatory work in the ZooAdministrator class:

You will define a collection for the visitors, so replace the following line: 

With this:

In the constructor you need to instantiate an empty collection, before the call to createExampleVisitors():

Define a method that returns the collection:

Modify the createExampleVisitors() method to utilise the collection rather than the previously named variables:

In virtualzoo.ui create a new class called VisitorTable which extends JTable:

The above class draws on very similar techniques to those shown in Section 14 for developing a JTable and associated TableModel:


Create a new tab in the constructor of AdministratorFrame:

The application should now look like this:

Next lesson: 18.2 Creating a menu bar

Related Posts

Leave Comments