初学java 编译时出错

issmqe 2007-10-24 04:07:12
出错信息:


hello.java:10:'{'expected
class ApplicationFram extends Fram implents ActionLister
hello.java:44:'}' expeted ^
}
^
2 errors











源程序:





import java.awt. *;
import java.awt.event. *;
public class Hello
{
public static void main(String args[]);
{
ApplicationFram AF=new ApplicationFram();
}
}
class ApplicationFram extends Fram implents ActionLister
{
Label prompt;
TextField text1,text2;
Button btn;
int a=0,b=0;

ApplicationFram()
{
super("我的窗口");
promt=new Label("请输入两个整数:");
text1=new TextField(4);
text2=new TextField(4);
btn=new Button("计算");
setLayout(new FlowLayout());
add(promt);
add(text1);
add(text2);
add(btn);
btn.addactionListener(this);
show();
}

public void actionPerformed(ActionEvent e)
{
a=Integer.parseInt(tex1.getText());
b=Integer.parseInt(tex2.getText());
}

public void paint(Graphics g)
{
g.drawString("运算结果:"+a+"*"+b+"="+a*b,20,80);
}

}









郁闷一下午了
...全文
84 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenggm 2007-10-24
  • 打赏
  • 举报
回复
改了下,可以运行了

public class Hello extends Frame {
Label prompt,label1;

TextField text1, text2,text3;

Button btn;
Button quit;
int a = 0;

int b = 0;

public Hello() {
try {
init();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args){
Hello hello = new Hello();
}
public void init() throws Exception {
prompt = new Label("请输入两个整数:");
label1 = new Label("=");
text1 = new TextField(4);
text2 = new TextField(4);
text3 = new TextField(4);
btn = new Button("计算");
quit = new Button("退出");
setLayout(new FlowLayout());
add(prompt);
add(text1);
add(text2);
add(label1);
add(text3);
add(btn);
add(quit);
btn.addActionListener(new Btn_actionAdapter(this));
quit.addActionListener(new Quit_actionAdapter(this));
this.setSize(500, 500);
this.setVisible(true);

}

public void quit_actionPerformed(ActionEvent e) {
System.exit(0);
}
public void bnt_actionPerformed(ActionEvent e) {
a = Integer.parseInt(text1.getText());
b = Integer.parseInt(text2.getText());
int result = a + b;
text3.setText(String.valueOf(result));
}



class Btn_actionAdapter implements ActionListener {
private Hello adaptee;

Btn_actionAdapter(Hello adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.bnt_actionPerformed(e);
}
}

class Quit_actionAdapter implements ActionListener {
private Hello adaptee;

Quit_actionAdapter(Hello adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.quit_actionPerformed(e);
}
}
}
issmqe 2007-10-24
  • 打赏
  • 举报
回复
谢谢两位
issmqe 2007-10-24
  • 打赏
  • 举报
回复
刚又看了一下,除了ls两位说的,还有好多
汗 不好意思
真不该问这样的问题
johnsoncr 2007-10-24
  • 打赏
  • 举报
回复
Fram implents --> Frame implements
shadao 2007-10-24
  • 打赏
  • 举报
回复
Fram
no no no
is Frame

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧