给你一个例子,但愿正确吧,未经测试,^_^
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.Container;
public class TestInput extends JApplet implements ActionListener
{
  JButton btn;
  JTextField text;
  Container c;
  public void init()
   {
     JOptionPane.showMessageDialog(null,"ds","df",1);
     c = getContentPane();
     c.setLayout(new BorderLayout());
     btn = new JButton("取得数字");
     text = new JTextField(10);
     btn.addActionListener(this);
     c.add(btn);
     c.add(text);
   }
   public void actionPerformed(ActionEvent e)
   {
    String value;
    value = JOptionPane.showInputDialog("请输入一个数字:");
    text.setText(value);
    }
}