java运行不出_我的java程序运行不了,不知道什么地方出了错误。

我的java程序运行不了,不知道什么地方出了错误。

21c92f7342edc52acb5684b0b88bdcec.png程序代码:import java.applet.*;

import java.awt.*;

import java.awt.event.*;

class Mycanvas extends Canvas

{int x,y;

Mycanvas(int a,int b)

{x=a;y=b;

setSize(100,160);

}

public void paint(Graphics g)

{g.setColor(Color.red);

g.fillOval(50,50,4*x,4*y);

g.drawString("我是第 "+x,10,150);

}

}

public class e123 extends Applet implements ActionListener

{

CardLayout mycard;

Button button1,button2,button3;

Mycanvas mycanvas[];

Panel p;

/** Initialization method that will be called after the applet is loaded

* into the browser.

*/

public void init() {

setLayout(new BorderLayout());

mycard=new CardLayout();

p=new Panel();

p.setLayout(mycard);

button1=new Button("first");

button2=new Button("next");

button3=new Button("last one");

mycanvas=new Mycanvas[21];

for(int i=1;i<=20;i++)

{mycanvas[i]=new Mycanvas(i,i);

p.add("i am"+i,mycanvas[i]);

}

button1.addActionListener(this);

button2.addActionListener(this); // TODO start asynchronous download of heavy resources

button3.addActionListener(this);

Panel p2=new Panel();

p2.add(button1);p2.add(button2);p2.add(button3);

add(p,BorderLayout.CENTER);add(p2,BorderLayout.SOUTH);

}

public void actionPerformed(ActiveEvent e)

{if(e.getSource()==button1)

{mycard.first(p);

}

else if(e.getSource()==button2)

{mycard.next(p);

}

else if(e.getSource()==button3)

{mycard.last(p);

}

}

}源代码:

但编译时出现错误:

e123.java:25: e123 不是抽象的,并且未覆盖 java.awt.event.ActionListener 中的抽象

方法 actionPerformed(java.awt.event.ActionEvent)

public class e123 extends java.applet.Applet implements ActionListener

^

e123.java:57: 找不到符号

符号: 方法 getSource()

位置: 接口 java.awt.ActiveEvent

{if(e.getSource()==button1)

^

e123.java:60: 找不到符号

符号: 方法 getSource()

位置: 接口 java.awt.ActiveEvent

else if(e.getSource()==button2)

^

e123.java:63: 找不到符号

符号: 方法 getSource()

位置: 接口 java.awt.ActiveEvent

else if(e.getSource()==button3)

^

4 错误

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值