一个java text的编程问题
import java.awt.*;import java.awt.event.*;
import java.applet.*;
public class TextFileldDemo extends Applet
implements ActionListener
{
TextField name,pass;
public void init(){
Label namep=new Label("Name:",Label.RIGHT);
Label passp=new Label("Password:",Label.RIGHT);
name =new TextField(12);
pass =new TextField(8);
pass.setEchoChar('?');
add(namep);
add(name);
add(passp);
add(pass);
name.addActionListener(this);
pass.addActionListener(this);
}
public void actionPerformed(ActionEvent ae){
repaint();
}
public void paint(Graphics g){
g.drawString("name:"+name.getText(),6,60);
g.drawString("Selectsd text in name:"+name.getSelectedText(),10,80);
g.drawString("Password:"+pass.getText(),20,100);
}
}
效果是在applet的下面出现文本输入区的内容,但是没有效果。
name.getText(),name.getSelectedText(),都没有响应。怎么回事??????????