这是一个applet程序,我想在同时输出一个字符串,可是不行,不知道为什么?(问题在程序中注释行标出了)请教
import java.awt.event.*;
import java.awt.*;
import java.applet.*;
public class Exam5_9 extends Applet implements AdjustmentListener
{
Scrollbar sb;
TextField text;
String str;
public void init()
{
setLayout(new BorderLayout());
sb=new Scrollbar(Scrollbar.HORIZONTAL,20,10,10,150);
sb.setBlockIncrement(20);
add("South",sb);
sb.addAdjustmentListener(this);
text=new TextField(20);
add("Center",text);
str="Here is an Applet.";
}
public void adjustmentValueChanged(AdjustmentEvent e)
{
int value=0;
if(e.getAdjustable()==sb)
{value=e.getValue();
text.setText(new Integer((int)value).toString());
text.setBackground(new Color(value,200,100));
}
}
public void paint(Graphics g)//为什么我不能把下面的字符串也输出到窗口中去?
{g.setColor(Color.black);
g.drawString(str,20,20);
}
}