Topic: Applet图形输入与输出 |
Print this page |
1.Applet图形输入与输出 | Copy to clipboard |
Posted by: 科大梦之队 Posted on: 2005-07-16 12:39 我的目标是:在图像界面输入一个数字,点击按钮输出平方结果。 import java.applet.*; import java.awt.*; import java.awt.event.*; public class AppletInOut extends Applet{ TextField in=new TextField(10); Button btn=new Button("求平方"); Label out=new Label("用于显示结果的标签"); public void init(){ setLayout(new FlowLayout()); add(in); add(btn); add(out); btn.addActionListener(new BtnActionAdapter()); } class BtnActionAdater implements ActionListener{ } public void actionPerformed(ActionEvent e){ String s=in.getText(); double d=Double.parseDouble; double sq=d*d; out.setText(d+" 的平方是"+sq); } } } 编译没通过:错误为: ---------------Configuration: AppletInOut - j2sdk1.4.2_07 <Default> - <Default>-------------------- C:\Program Files\Xinox Software\JCreatorV3\MyProjects\AppletInOut\src\AppletInOut.java:6: illegal character: \65307 Button btn=new Button("pingfang"); ^ C:\Program Files\Xinox Software\JCreatorV3\MyProjects\AppletInOut\src\AppletInOut.java:7: illegal character: \65307 Label out=new Label("wome"); ^ C:\Program Files\Xinox Software\JCreatorV3\MyProjects\AppletInOut\src\AppletInOut.java:21: illegal character: \65291 out.setText(d+" fdfefe"+sq); ^ C:\Program Files\Xinox Software\JCreatorV3\MyProjects\AppletInOut\src\AppletInOut.java:24: 'class' or 'interface' expected } ^ C:\Program Files\Xinox Software\JCreatorV3\MyProjects\AppletInOut\src\AppletInOut.java:24: 'class' or 'interface' expected } ^ 5 errors Process completed. 恳请大侠帮助~~~ |
2.Re:Applet图形输入与输出 [Re: 科大梦之队] | Copy to clipboard |
Posted by: bohui0714 Posted on: 2005-07-16 16:51 //你太马虎了 //java:6和java:7的错误是分号是全角的 //java:21,错误是“+”号是全角的 //java:24,你的事件响应程序写到了class BtnActionAdapter的外边 import java.awt.*; import java.applet.*; import java.awt.event.*; public class t1 extends Applet{ TextField in=new TextField(10); Button btn=new Button("Button 1"); Label out=new Label("Result"); public void init(){ setLayout(new FlowLayout()); add(in); add(btn); add(out); btn.addActionListener(new BtnActionAdapter()); } class BtnActionAdapter implements ActionListener{ public void actionPerformed(ActionEvent e){ String s=in.getText(); double d=Double.parseDouble; double sq=d*d; out.setText(d+" Square"+sq); } } } |
3.Re:Applet图形输入与输出 [Re: 科大梦之队] | Copy to clipboard |
Posted by: 科大梦之队 Posted on: 2005-07-17 09:59 bohui0714 ,你找出的问题我看了一下,果然是这样,我这是第一次知道,JAVA对全角还敏感的,十分感谢你的帮助。 |
4.Re:Applet图形输入与输出 [Re: 科大梦之队] | Copy to clipboard |
Posted by: 阿圆 Posted on: 2005-07-17 16:27 不仅如此,JAVA对括号的匹配也很敏感。 { ]就会出错。 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |