Would any body tell me that what is the function of setAction command in the following code. I got beet confuse about this command. Also i would like to know since getActionCommand is a method of Button class then How we r calling it with ActionEvent object.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class first extends
Applet implements ActionListener{
Button left,right;
TextField display;
Button btn2=new Button("CANCEL");
public void init(){
left=new Button("Gauche");
add(left);
display=new TextField(5);
add(display);
right=new Button("Droit");
add(right);
left.addActionListener(this);
right.addActionListener(this);
left.setActionCommand("Left");
right.setActionCommand("right");
}
public void actionPerformed(ActionEvent e){
String s=e.getActionCommand();
if(s.equals("left"))
display.setText("<---------");
else
if(s.equals("right"))
display.setText("-------->");
}
}
Thanks