Question To be answered in (13) Minutes / 2.5 Marks GUI Example Green Yellow Red Display Light: Green A user can control
Posted: Fri May 20, 2022 12:08 pm
Question To be answered in (13) Minutes / 2.5 Marks 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 iframe (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 7 i Complete the missing parts in Tlight class for GUI // Class declaration part (0.5 pt) class Change Light // you must correct the class declaration // Components declaration and instantiation JPanel lights - new JPanelo: JPanel display = new JPanelo: 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 Changel.ight i/fill in the missing code under here. Iall components and panels have been I/declared previously. // set other properties of JFrame setVisible(true): setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE): setSize(300, 150): setTitle("GUI Example"): 1 @Override public void action Performed(ActionEvent ae) { // complete handling the events and setting the text of the activel.ight label to // the corresponding light
import javax.swing. import java.awt.event.": import java.awt.: public class Graphic Test public static void main(String args) { // fill in code here 7 i Complete the missing parts in Tlight class for GUI // Class declaration part (0.5 pt) class Change Light // you must correct the class declaration // Components declaration and instantiation JPanel lights - new JPanelo: JPanel display = new JPanelo: 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 Changel.ight i/fill in the missing code under here. Iall components and panels have been I/declared previously. // set other properties of JFrame setVisible(true): setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE): setSize(300, 150): setTitle("GUI Example"): 1 @Override public void action Performed(ActionEvent ae) { // complete handling the events and setting the text of the activel.ight label to // the corresponding light