Create an ACM Graphics program named Marquee that displays a scrolling message. Your program will have widgets to allow the user to enter a new message and to change the color of the display.

Here are the instructions:

* Plan on making the program 600 wide and 200 high. Center the message vertically on the screen. You can set the application width and height as described.
* You'll need a GLabel for the message, two JButtons and a JTextField as shown in the example here.
* When you first position your label, position it off the right side of the screen. As you draw each frame of your animation, move it to the left by two pixels. When the entire label has scrolled off the screen to the left, position it back on the right-hand side again.
* When the GO button is pressed, grab the text from the JTextField and use it to change the message displayed in your label.
* When the Color button is pressed, select a new color. You can use an array of colors and cycle through them, or you can choose a color at random.

I'm having problem with the last 2 instructions, the GO button and the Color Button. Can anyone help?


Here's the codes:
Java Code:


import acm.program.*;
import acm.graphics.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;


public class Marquee extends GraphicsProgram
{
private GRect myWidget;
private JButton Go;
private JTextField textBox;
private JButton color;
private GLabel label;


/**
 * Application Width.
 */
public static final int APPLICATION_WIDTH = 600;
/**
 * Application Height.
 */
public static final int APPLICATION_HEIGHT = 200;

public void init()
{
    myWidget = new GRect(1,1,600,200);
    myWidget.setFillColor(Color.RED);
    myWidget.setFilled(true);
    add(myWidget);

    Go = new JButton("GO");
    add(Go, SOUTH);
    textBox = new JTextField("                                       ");
    add(textBox, SOUTH);
    color = new JButton("Color");
    add(color, SOUTH);
    String txt = textBox.getText();
   
    this.addActionListeners();
    this.addMouseListeners();
   
}

public void actionPerformed(ActionEvent e)
{
    Object clicked = e.getSource();
   
    if (clicked == Go)
    {
        // Get the text from textBox replace it with original text. (here is where i need help)
    }
    if (clicked == color)
    {
        // Change text color. (i need help here also)
    }
}

/**
* Illustrate some ACM graphical interfaces.
*/
public void run()
{
    int xPos = 400;
    label = new GLabel("Type in your new message");
    add(label);
    label.setFont(new Font("Arial", Font.BOLD, 50));
    while (true)
    {
        label.setLocation(xPos, 90);
        xPos -= 2;
        xPos = (xPos <= 0) ? 600 : xPos;
        pause(20);
    }
}
/**
* The standard Java entry point. DON'T MODIFY.
*
* @param args the command-line arguments.
*/
public static void main(String[] args)
{
new Marquee().start(args);
}
}