Reference no: EM13161500
For this assignment you are to create an interactive moving sign in the context of a cityscape street scene. Click the link below to see how a base version of this assignment works. Type a message in the long blank slot at the top left, and then click Start to see the message displayed in a moving format.
The driver and DisplayWindow classes, which you may NOT alter, are provided here:
import javax.swing.*;
/* Menu machinery provided, but you are free
* to ignore it if your solution does not involve menus
*/
public class SignDriver {
public static void main(String[] args) {
DisplayWindow d = new DisplayWindow();
JMenuBar menuBar = new JMenuBar(); // make menu bar
d.setJMenuBar(menuBar); // add menu bar to window d
MovingSignPanel p = new MovingSignPanel(menuBar);
d.addPanel(p);
d.showFrame();
}
}
--------------------------
package owl.common;
import javax.swing.*;
import java.awt.*;
/**
* A class that puts a graphics window on your display
*/
public class DisplayWindow extends JFrame {
/**
* Content pane that will hold the added Jpanel
*/
private Container c;
/**
* DisplayWindow constructor - no parameters
*/
public DisplayWindow() {
super("Display");
c = this.getContentPane();
}
/**
* Adds panel to content pane
*
* @parameter the panel to be added
*/
public void addPanel(JPanel p) {
c.add(p);
}
/**
* consolidates the frame, makes it visible, causes program termination when
* window is closed manually
*/
public void showFrame() {
this.pack();
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
-------
Note that the application will makes use of the DisplayWindow class that figures prominently in Chapters 12 and 13 of the textbook. For this assignment you need only submit a single file, MovingSignPanel.java (must be so named), which extends JPanel in the standard way, and which carries out the main actions of the assignment.
Other issues
* The cityscape presented above in the running demonstration code is pathetic - there's just one building, no sky to speak of, etc. You are encouraged to vastly improve on the rendering of the cityscape. Ideas: more buildings; the sky can become lighter or darker over time; lights can go on in some of the windows in the buildings; you could add a park, a flagpole, the sun, the moon, cars, flying saucers; you can make the sign move faster or slower, and so forth.
* The SignDriver code includes machinery for including a menu or menus in your application. You DO NOT need to use this machinery. But if you decide to add menus, it's there.