/**
* Title: class RobotFrame
* Description: Class to display a window for the robot program.
* Copyright (c) 2001
* Organisation: UCL
* @author Graham Roberts
* @version 1.1 10/03
*/
import javax.swing.* ;
import java.awt.* ;
import java.awt.event.* ;
class RobotFrame extends JFrame
{
private Room room ;
// Create a new window frame.
public RobotFrame(String name, Room room)
{
super(name) ;
this.room = room ;
setUpWindow() ;
}
private void setUpWindow()
{
// Create the contents of the window. The top (or Center)
// part is the drawing area. The bottom (or South) strip
// holds a quit button.
JPanel buttonPanel = new JPanel() ;
buttonPanel.setLayout(new BorderLayout()) ;
JButton quitButton = new JButton("Quit") ;
buttonPanel.add("Center",quitButton) ;
getContentPane().setLayout(new BorderLayout()) ;
getContentPane().add("Center",room) ;
getContentPane().add("South",buttonPanel) ;
// The event listeners are set up here to enable the
// program to respond to events.
quitButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
quit() ;
}
}) ;
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent evt)
{
quit() ;
}
}) ;
}
// This will terminate the program when the user
// wants to quit.
private void quit()
{
System.exit(0) ;
}
}