import java.awt.*;
import java.awt.event.*;public class a {
public static void main(String[] args) {
new TFFrame();
}
}class TFFrame extends Frame {
TextField num1,num2,num3; TFFrame(){
num1 = new TextField(5);
num2 = new TextField(5);
num3 = new TextField(10);
Label jia = new Label("+");
Button result = new Button("=");
add(num1);
add(jia);
add(num2);
add(result);
add(num3);
setLayout(new FlowLayout());
pack();
setVisible(true);
result.addActionListener(new jianting(this));
}
}
class jianting implements ActionListener {
TFFrame frame = null;
public jianting(TFFrame frame) {
this.frame=frame;
}
public void actionPerformed(ActionEvent e) {
int n1 = Integer.parseInt(frame.num1.getText());
int n2 = Integer.parseInt(frame.num2.getText());
frame.num3.setText=("" + (n1+n2));
}
}
import java.awt.event.*;public class a {
public static void main(String[] args) {
new TFFrame();
}
}class TFFrame extends Frame {
TextField num1,num2,num3; TFFrame(){
num1 = new TextField(5);
num2 = new TextField(5);
num3 = new TextField(10);
Label jia = new Label("+");
Button result = new Button("=");
add(num1);
add(jia);
add(num2);
add(result);
add(num3);
setLayout(new FlowLayout());
pack();
setVisible(true);
result.addActionListener(new jianting(this));
}
}
class jianting implements ActionListener {
TFFrame frame = null;
public jianting(TFFrame frame) {
this.frame=frame;
}
public void actionPerformed(ActionEvent e) {
int n1 = Integer.parseInt(frame.num1.getText());
int n2 = Integer.parseInt(frame.num2.getText());
frame.num3.setText=("" + (n1+n2));
}
}
解决方案 »
- Dynamic Proxy 在 Java RMI 中的应用 学习疑问
- 快来回答,高分-------怎样用Java代码,访问outlook。
- 请问利用SNMP,如何能让被管理设备执行PING操作!
- 安装JDK时,遇到超级慢的情况——从上午11点到下午2点多孩么装完。无奈~~ 其他人都是这样的吗?
- 一个简单问题,请简单回答,谢谢!
- 走过、路过的都请来帮忙答题02,多谢!!!
- 查找JAVA资源
- 如何用JCreator对JAVA源文件进行编译?
- 大家能否帮我一下,特急!求求大家了。
- 【JAVA------>怎么设置Application的背景图片】
- 很诡异的问题,关于jenkins,openjdk,hotspotjdk的
- 关于javac的问题!!在线急需解决方法!!高分悬赏
class jianting implements ActionListener {
TFFrame frame = null;
public jianting(TFFrame frame) {
this.frame=frame;
}
public void actionPerformed(ActionEvent e) {
int n1 = Integer.parseInt(frame.num1.getText());
int n2 = Integer.parseInt(frame.num2.getText());
errorow:frame.num3.setText=("" + (n1+n2));
}
}改为:class jianting implements ActionListener {
TFFrame frame = null;
public jianting(TFFrame frame) {
this.frame=frame;
}
public void actionPerformed(ActionEvent e) {
int n1 = Integer.parseInt(frame.num1.getText());
int n2 = Integer.parseInt(frame.num2.getText());
errorrow:frame.num3.setText("" + (n1+n2)); //函数写法错了,估计是笔误
}
}
多了“=”
用myeclipse很容易找出来
import java.awt.event.*;public class a {
public static void main(String[] args) {
new TFFrame();
}
}class TFFrame extends Frame {
TextField num1,num2,num3; TFFrame(){
num1 = new TextField(5);
num2 = new TextField(5);
num3 = new TextField(10);
Label jia = new Label("+");
Button result = new Button("=");
add(num1);
add(jia);
add(num2);
add(result);
add(num3);
setLayout(new FlowLayout());
pack();
setVisible(true);
result.addActionListener(new jianting(this));
}
}
class jianting implements ActionListener {
TFFrame frame = null;
public jianting(TFFrame frame) {
this.frame=frame;
}
public void actionPerformed(ActionEvent e) {
int n1 = Integer.parseInt(frame.num1.getText());
int n2 = Integer.parseInt(frame.num2.getText());
frame.num3.setText=("" + (n1+n2));你这里干嘛加的=号?
}
}
有个warning在TFFramehttp://www.blogjava.net/invisibletank/archive/2007/11/15/160684.html希望对你有用