- Compile Lights.java
- Run Lights as a Java application. (If possible do all this within Eclipse, although this is not essential)
- In America, the lights go straight from red to green (ie there is no intermediate red-amber step). Alter the code to do this.
- Add another button which switches off all the lights.
(you may need to use the getSource() method
in your actionPerformed method to find out which of the buttons was pressed.
- Add a button which changes the size of the lights each time it is pressed. (Harder)
- Think about how to change the size of the lights with a slider. Look up on the web about how to use JSliders.
Sebastian Danicic BSc MSc PhD (Reader in Computer Science)
Dept of Computing, Goldsmiths, University of London, London SE14 6NW
Last updated 2015-09-04