Page 1 of 1

tion 1: To be answered in (15) Minutes / 2.5 Marks X GUI Example Green Yellow Red Display Light: Green A user can contro

Posted: Fri May 20, 2022 10:16 am
by answerhappygod
Tion 1 To Be Answered In 15 Minutes 2 5 Marks X Gui Example Green Yellow Red Display Light Green A User Can Contro 1
Tion 1 To Be Answered In 15 Minutes 2 5 Marks X Gui Example Green Yellow Red Display Light Green A User Can Contro 1 (39.57 KiB) Viewed 28 times
Tion 1 To Be Answered In 15 Minutes 2 5 Marks X Gui Example Green Yellow Red Display Light Green A User Can Contro 2
Tion 1 To Be Answered In 15 Minutes 2 5 Marks X Gui Example Green Yellow Red Display Light Green A User Can Contro 2 (46.83 KiB) Viewed 28 times
tion 1: To be answered in (15) Minutes / 2.5 Marks X GUI Example Green Yellow Red Display Light: Green 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.

import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Graphic Test { public static void main(String[] args) { // fill in code here } } 1/ Complete the missing parts in Tlight class for GUI // Class declaration part (0.5 pt) class ChangeLight { // you must correct the class declaration // Components declaration and instantiation JPanel lights = new JPanel(); JPanel display = new JPanel(); JLabel disLabel = new JLabel("Display Light:"); JLabel activeLight = new JLabel("Green"); JButton green = new JButton("Green"); JButton yellow = new JButton("Yellow"); JButton red = new JButton("Red"); public ChangeLight( { l/fill in the missing code under here, l/all components and panels have been //declared previously. // set other properties of JFrame setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(300, 150); setTitle("GUI Example"); 3 @Override public void action Performed(ActionEvent ae) { // complete handling the events and setting the text of the activeLight label to // the corresponding light