河南成教 / Java程序设计
[简答题] 阅读下列程序,写出程序功能。
import java.applet.*;import java.awt.*;
import java.awt.event.*;
public class Class36004 extends Applet implements KeyListener
{
int count=0;
TextArea text=new TextArea(5,20);
public void init()
{
add(text);
text.addKeyListener(this);
}
public void keyPressed(KeyEvent e)
{
int t =e.getKeyCode();
if(t>=KeyEvent.VK_0 && t<=KeyEvent.VK_9)
{
text.append("*");count ++;
if(count %10==0) text.append("\n");
}
else
text.setEditable(false);
}
public void keyTyped(KeyEvent e){}
public void keyReleased(KeyEvent e){}
}
import java.applet.*;import java.awt.*;
import java.awt.event.*;
public class Class36004 extends Applet implements KeyListener
{
int count=0;
TextArea text=new TextArea(5,20);
public void init()
{
add(text);
text.addKeyListener(this);
}
public void keyPressed(KeyEvent e)
{
int t =e.getKeyCode();
if(t>=KeyEvent.VK_0 && t<=KeyEvent.VK_9)
{
text.append("*");count ++;
if(count %10==0) text.append("\n");
}
else
text.setEditable(false);
}
public void keyTyped(KeyEvent e){}
public void keyReleased(KeyEvent e){}
}
参考答案:
佳题速递: