Needed help in actionPerformed statements
Question:
http://img819.imageshack.us/img819/2123/javaz.jpg
Here's the code that I have done:
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class GUI extends JFrame implements ActionListener
{
JButton btn1;
JButton btn2;
JButton btn3;
JTextArea area1;
GUI()
{
setLayout (new BorderLayout());
btn1 = new JButton ("Elephant");
btn2 = new JButton ("Mickey");
btn3 = new JButton ("Butterfly");
area1 = new JTextArea ("");
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
p1.add (btn1);
p1.add (btn2);
p1.add (btn3);
p2.add (area1);
add(p2, BorderLayout. CENTER);
add(p1, BorderLayout. SOUTH);
}
public static void main (String []args)
{
String [] photos = {"elephant.jpg", "mickey.jpg", "butterly.jpg"};
GUI t = new GUI();
t.setSize(500,150);
t.setVisible(true);
t.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
t.setTitle("Button and Icons");
}
public void actionPerformed(ActionEvent evt)
{
if(evt.getSource() == btn1)
{
area1.append();
}
}
}
Can anyone help me to tell me what should I write at the 'public void actionPerformed(ActionEvent evt)'?? Thanks (=