Hello All ---
I am working on the following assignment and need a little bit of help with my code.
Write a program that has three buttons, each displaying a different text that when pressed will display the text on the button in a text box. (For an extra challenge, have the user choose the color of the displayed text as well).
This is my code so far.
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.*;
class button extends Frame
{
button()
{
TextField objTextf;
setTitle("press the button");
setSize(300,300);
show();
}
public static void main(String[] args)
{
Frame objFrame;
Button objbutton1;
Button objbutton2;
Button objbutton3;
objFrame = new button();
objbutton1 = new Button("hello");
objbutton2 = new Button("Hola");
objbutton3 = new Button("Guten Tag");
objTextf = new TextField("trial");
objbutton1.setBounds(180,150,80,50);
objbutton2.setBounds(100,150,80,50);
objbutton3.setBounds(20,150,80,50);
objFrame.add(objbutton1);
objFrame.add(objbutton2);
objFrame.add(objbutton3);
objFrame.add(objTextf);
objbutton1.addActionListener(new button1Listener());
objbutton2.addActionListener(new button2Listener());
objbutton3.addActionListener(new button3Listener());
}
public class button1Listener
{
public void buttonpushed(ButtonEvent me)
{
String S = objTextf.getText();
objTextf.setText(S);
}
}
}
I am getting the error message --- cannot find symbol - class ButtonEvent ---
The following line is highlighted -- public void buttonpushed(ButtonEvent me)
Any help and advice is greatly appreciated! Thank you!