Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Identify errors and correct them of the following Java program: (10 marks) 1. import java.swing.*; 2. import java.awt.*; 3. import java.awt.event.* 4. public class ColorWindow

Identify errors and correct them of the following Java program: (10 marks)

1. import java.swing.*;

2. import java.awt.*;

3. import java.awt.event.*

4. public class ColorWindow extends Frame

5. {

6. private JLabel messageLabel;

7. private JButton redButton;

8. private JPanel panel;

9. private final int WINDOW_WIDTH = 200;

10. private final int WINDOW_HEIGHT = 125;

11. public ColorWindow

12. {

13. setTitle("Colors");

14. setSize(WINDOW_WIDTH, WINDOW_HEIGHT);

15. setDefaultCloseOperation(JFrame.EXIT);

16. messageLabel = new JLabel("Click the button to " + "apply red color.");

17. redButton = new JButton("Red");

18. redButton.addActionListener(new RedButtonListener());

19. panel = new JPanel();

20. panel.add(messageLabel);

21. panel.add(redButton);

22. add(panel);

23. setVisible(true);

24. }

25. private class RedButtonListener implements ActionListener

26. {

27. public void actionPerformed(ActionEvent e)

28. {

29. panel.setBackground(Color.RED);

30. messageLabel.setForeground(Color.BLUE);

31. }

32.

33. public static void main(String[] args)

34. {

35. new ColorWindow();

36. }

37. }

Identify 5 errors and give their Line Number, Error description and Statement after correction.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

What is paper chromatography?

Answered: 1 week ago

Question

Explain the cost of capital.

Answered: 1 week ago

Question

Define capital structure.

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago