Professional Documents
Culture Documents
Quiz2 CS CS151 141 1 22
Quiz2 CS CS151 141 1 22
Student Name:
Student ID:
Course Code:
Section No.:
Instructions:
1. Write your answers directly on the question sheets. Use the ends of the question
pages for rough work or if you need extra space for your answer.
2. If information appears to be missing from a question, make a reasonable
assumption, state your assumption, and proceed.
Page 1 of 3
A user can control the Display light in the application by pressing on the buttons at the
top of the main Jframe (using FlowLayout). When a button is pressed, the label ‘activeLight’ on
the right of the label "Display Light" (both labels are inside a panel that uses Flowlayout)
changes according to the corresponding light. The default text of activeLight is "Green".
Complete the following code skeleton (next page) to reproduce the same interface and
interaction using Java Swing/Awt libraries and event handling components. Upload your java
file or compress and upload it.
Page 2 of 3
public ChangeLight() {
//fill in the missing code under here,
//all components and panels have been
//declared previously.
@Override
public void actionPerformed(ActionEvent ae) {
// complete handling the events and setting the text of the activeLight label to
// the corresponding light
}
}
Page 3 of 3