高手帮改改?我是小菜鸟
程序代码:
import java.applet.*; import java.awt.*; import java.awt.event.*; public class LeapyearTest extends Applet implements ActionListener // 继承类 Applet 并实现接口 ActionListener { public static void main(String args[]) { Frame frame =new Frame(); //创建 Frame 的实例(对象) LeapyearTest lea=new LeapyearTest(); lea.init(); frame.add(lea); frame.setSize(400,100); frame.show(); } Label result; TextField t1; Button btn; int year; boolean leap; result=new Label("请输入要判断的年份 "); t1=new TextField(5); btn=new Button("判断"); public void init() { //result=new Label("请输入要判断的年份 "); //t1=new TextField(5); //btn=new Button("判断"); setLayout(new FlowLayout()); add(t1); add(btn); add(result); btn.addActionListener(this); } public void actionPerformed(ActionEvent e) { year=Integer.parseInt(t1.getText()); if((year%4==0)&&((year%100)!=0)) leap=true; else if(year%400==0) leap=true; else leap=false; if(leap=true) result.setText(year+"年是闰年"); else result.setText(year+"年不是闰年"); t1.setText(""); } }
结果成了:
LeapyearTest.java:24: 需要 <标识符>
result=new Label("请输入要判断的年份: "
^
LeapyearTest.java:24: 非法字符: \65307
result=new Label("请输入要判断的年份: "
^
LeapyearTest.java:26: 需要 <标识符>
btn=new Button("判断");
^
LeapyearTest.java:40: 非法字符: \65288
if((year%4==0)&&((year%100)!=0))
^
LeapyearTest.java:40: 非法字符: \65289
if((year%4==0)&&((year%100)!=0))
^
LeapyearTest.java:40: 非法字符: \65288
if((year%4==0)&&((year%100)!=0))
^
LeapyearTest.java:40: 非法字符: \65289
if((year%4==0)&&((year%100)!=0))
^
LeapyearTest.java:41: 需要 ')'
leap=true;
^
LeapyearTest.java:50: 非法字符: \65307
result.setText(year+"年不是闰年");
^
9 错误
请问出现这些情况应该怎么修改和出错的原因?
[[it] 本帖最后由 mx250052 于 2009-7-13 18:06 编辑 [/it]]