welldefined
Programmer
Hi,
I tried following code and it looks fine. It does not need a "lestioner" to fire the return key press event.
1. Can you check if this code is OK?
2. If this code is OK, why we need to use "listioner"?
import java.applet.Applet;
import java.awt.*;
public class ListPrime extends Applet
{
Label Label1; TextField Text1;
public void init()
{
Label1=new Label("");
Text1=new TextField(4);
add(Label1);
add(Text1);
}
public boolean action(Event e, Object o)
{
if(e.target==Text1)
Label1.setText(Text1.getText());
return true;
}
}
I tried following code and it looks fine. It does not need a "lestioner" to fire the return key press event.
1. Can you check if this code is OK?
2. If this code is OK, why we need to use "listioner"?
import java.applet.Applet;
import java.awt.*;
public class ListPrime extends Applet
{
Label Label1; TextField Text1;
public void init()
{
Label1=new Label("");
Text1=new TextField(4);
add(Label1);
add(Text1);
}
public boolean action(Event e, Object o)
{
if(e.target==Text1)
Label1.setText(Text1.getText());
return true;
}
}