【代码】Applet实现,页面选择gbk编码
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Add extends Applet implements ActionListener
{
Label lblTwoNum = new Label ("请输入两个数字");
Label lblAdd = new Label ("此处显示答案");
TextField txtFirstNum = new TextField (2);
TextField txtSecNum = new TextField (2);
Button btnAdd = new Button ( "求和");
public void init()
{
add (lblTwoNum);
add (txtFirstNum);
add (txtSecNum);
add (btnAdd);
add (lblAdd);
this.resize(300,100);
btnAdd.addActionListener (this);
}
public void actionPerformed (ActionEvent e)
{
String firstNum = txtFirstNum.getText();
String secNum = txtSecNum.getText();
int add = Integer.parseInt(firstNum) + Integer.parseInt(secNum);
lblAdd.setText ("两数之和:"+ add);
}
}
如果不会调试可以百度Hi我~~
你用的是SWT还是RCP啊 在RCP中实现很简单,只需相应的包即可
你是谁,这么巧?
Swing界面啊