Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Below is a Java program intended to produce a GUI with two buttons. Each butt

ID: 640444 • Letter: 1

Question

1. Below is a Java program intended to produce a GUI with two buttons. Each button should change colors when pressed. Cut and paste this code into an editor to work on it. You can save the whole thing as Changer.java. Read the error messages to figure out why the program doesn't compile and fix it. Once it compiles and runs, it probably won't behave correctly. Find the mistakes in the code and fix them. HINT: There are no errors in the ColorChange class. You can ignore that piece of the code if you want.

2. (6 points) Write a program which creates a JFrame with two JLabels in it. The JFrame should be colored green (using getContentPane().setBackground()) of size 500 by 400. One label should be blue and the other red. We saw in class that just setting the background of a JLabel doesn't seem to have any effect. You need to also call setOpaque(true); on each label to make the color visible. By default, JLabels have transparent backgrounds.

Now using this program to experiment, draw a sketch of the window in each of the following situations:

FlowLayout

GridLayout(3,1)

GridLayout(3,2)

BorderLayout with labels at NORTH and SOUTH

BorderLayout with labels at NORTH and CENTER

BorderLayout with labels at WEST and SOUTH

Show your sketches

Explanation / Answer

second one still i am trying...in less time i will update