tion 1: To be answered in (15) Minutes / 2.5 Marks X GUI Example Green Yellow Red Display Light: Green A user can contro
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
tion 1: To be answered in (15) Minutes / 2.5 Marks X GUI Example Green Yellow Red Display Light: Green A user can contro
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