|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectbecker.robots.RobotUIComponents
public class RobotUIComponents
A factory object that provides the major user interface components, making customized user interfaces easy to create.
For example, CityFrame contains the following code
using RobotUIComponents in its constructor:
public CityFrame(City model, int firstVisibleStreet, int firstVisibleAvenue,
int numVisibleStreets, int numVisibleAvenues)
{ super();
this.frame = new JFrame("Robots: Learning to program with Java");
this.frame.addWindowListener(new WindowCloser());
this.ui = new RobotUIComponents(model, firstVisibleStreet, firstVisibleAvenue,
numVisibleStreets, numVisibleAvenues);
this.frame.setJMenuBar(ui.getMenuBar());
JPanel view = new JPanel(new BorderLayout());
CityView sp = ui.getCityView();
view.add(sp, BorderLayout.CENTER);
view.add(ui.getControlPanel(), BorderLayout.EAST);
this.frame.setContentPane(view);
this.frame.pack();
this.frame.repaint();
this.frame.setVisible(true);
}
| Constructor Summary | |
|---|---|
RobotUIComponents(City model)
Create the components for a default view of the city using the defaults in becker.robots.ini for the visible streets and avenues and intersection size. |
|
RobotUIComponents(City model,
int leftAve,
int topStr,
int width,
int height)
Create the components to view a specified section of the city. |
|
RobotUIComponents(City model,
int leftAve,
int topStr,
int width,
int height,
int simSize)
Create the components to view a specified section of the city. |
|
| Method Summary | |
|---|---|
CityView |
getCityView()
Get a component that shows the city and the city's scrollbars. |
JPanel |
getControlPanel()
Get a panel grouping the start/stop button and speed slider together |
JMenuBar |
getMenuBar()
Get the menu bar for the user interface. |
JSlider |
getSpeedSlider()
Get a slider to control the speed of the animation. |
JButton |
getStartStopButton()
Get a button to start and stop the animation |
JPanel |
getUI()
Get a panel grouping the city's view with the traditional control panel. |
JSlider |
getZoom()
Get a component that causes the view to zoom in on the city |
void |
quitApp()
Quit the application. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RobotUIComponents(City model)
model - the city to show
public RobotUIComponents(City model,
int leftAve,
int topStr,
int width,
int height,
int simSize)
model - the city to showleftAve - the leftmost avenue to showtopStr - the topmost street to showwidth - the number of avenues to showheight - the number of streets to showsimSize - the size, in pixels, of each sim (ie: the size of one intersection)
public RobotUIComponents(City model,
int leftAve,
int topStr,
int width,
int height)
model - the city to showleftAve - the leftmost avenue to showtopStr - the topmost street to showwidth - the number of avenues to showheight - the number of streets to show| Method Detail |
|---|
public JSlider getSpeedSlider()
public JButton getStartStopButton()
public CityView getCityView()
public JSlider getZoom()
public JPanel getControlPanel()
public JPanel getUI()
public JMenuBar getMenuBar()
public void quitApp()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||