The AdministratorFrame class
The frame now only needs to show ZooKeeperPanel inside a tab of a JTabbedPane. Create a class in virtualzoo.ui called AdministratorFrame:
package virtualzoo.ui;
import java.awt.*;
import javax.swing.*;
public class AdministratorFrame extends JFrame {
public AdministratorFrame() {
super("Zoo Administrator");
setLayout(new BorderLayout());
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
// Create tabbed pane
JTabbedPane tabPane = new JTabbedPane();
// Create zoo keeper panel
ZooKeeperPanel zooKeeperPanel = new ZooKeeperPanel();
tabPane.addTab("Zoo Keepers", zooKeeperPanel);
add(tabPane, BorderLayout.CENTER);
// Set components to their preferred size
pack();
// Place in the centre of the desktop
setLocationRelativeTo(null);
// Make the frame visible
setVisible(true);
}
}
Change the main() method of VirtualZoo to instantiate AdministratorFrame (you will need to import virtualzoo.ui):
public static void main(String[] args) {
AdministratorFrame frame = new AdministratorFrame();
}
At this point you can run the application to ensure it appears as below:
You will note that after entering some details and clicking the Save button the added zookeeper is not appearing in the list on the left. This will be addressed in the next lesson.
Comments