为什么我的paint方法好像不管用啊
import java.awt.*;//import javax.swing.*;
import java.awt.event.*;
public class Wenbenkuang extends Frame implements WindowListener,ActionListener,TextListener
{
Label l1,l2,l3;
TextField t1,t2,t3;
int i;
String str;
float ft;
public Wenbenkuang()
{
Frame ff=new Frame("我的窗口");
ff.setSize(400, 800);
ff.setLocation(400, 400);
l1=new Label("请输入整数:");
t1=new TextField("0",30);
ff.add(l1);
ff.add(t1);
t1.addTextListener(this);
l2=new Label("请输入字符串:");
t2=new TextField(" ",30);
ff.add(l2);
ff.add(t2);
t2.addTextListener(this);
l3=new Label("请输入浮点数:");
t3=new TextField(" ",30);
ff.add(l3);
ff.add(t3);
t3.addTextListener(this);
ff.addWindowListener(this);
ff.setLayout(new FlowLayout());
ff.setVisible(true);
}
public void windowClosing(WindowEvent e)
{
Window ww=(Window)e.getSource();
ww.setVisible(false);
ww.dispose();
}
public void actionPerformed(ActionEvent e)
{
i=Integer.parseInt(t1.getText());
str=t2.getText();
ft=(Float.valueOf(t3.getText())).floatValue();
repaint();
}
public void paint(Graphics g)
{
g.drawString("整形数:"+this.i,20,120);
g.drawString("字符串:"+this.str, 20, 150);
g.drawString("浮点数: "+this.ft, 20, 180);
}
public void textValueChanged(TextEvent t)
{
}
public static void main(String[] args)
{
Wenbenkuang w1=new Wenbenkuang();
}
@Override
public void windowActivated(WindowEvent e) {
// TODO 自动生成的方法存根
}
@Override
public void windowClosed(WindowEvent e) {
// TODO 自动生成的方法存根
}
@Override
public void windowDeactivated(WindowEvent e) {
// TODO 自动生成的方法存根
}
@Override
public void windowDeiconified(WindowEvent e) {
// TODO 自动生成的方法存根
}
@Override
public void windowIconified(WindowEvent e) {
// TODO 自动生成的方法存根
}
@Override
public void windowOpened(WindowEvent e) {
// TODO 自动生成的方法存根
}
}
我只是想让三个文本框里的内容一块显示出来