给你一个例子,但愿正确吧,未经测试,^_^
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);
}
}
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);
}
}
解决方案 »
- 关于线程的一个小问题~
- java import 自定义类
- Java Timer And TimerTask执行频率 精确认执行问题
- 一般泛型用的貌似不多
- 使用Apache的upload组件问题
- PrintWriter输出时怎么才能不覆盖以前的内容
- 在图形用户界面中,向一个文本区输入一个文件流,文本区加了滚动条,怎样使滚动条随着文件增多而滚动啊?
- 帮帮我啊
- 如何取得文本框輸入之前的值
- 请问一道题目,谢谢
- 用PreparedStatement ps 在数据库中插入记录,但还未提交事务,此时再用Delete语句为什么删除不了用 ps刚才插入的记录,如何可以删除未这
- 照书抄了个程序都出错,哪位朋友帮我找找错?
int number = Integer.parseInt(String变量);