1

ここに私がコンパイルしようとしているコードがあります.私が得るすべてはこのようなエラーです

s09_02 は抽象ではなく、java.awt.event.ActionListener の抽象メソッド actionPerformed(java.awt.event.ActionEvent) をオーバーライドしません。

私の質問は、クラスが抽象でない場合、どのように ActionListener をクラス (s09_02) に実装できますか?

コード全体は次のとおりです(問題がどこにあるのかわかりません)

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class s09_02 extends Applet implements ActionListener{
public void init()
 {
  setLayout(null);
  setBackground(new Color(0,10,100));
 }
 public void paint(Graphics p){String t=null;
 int x,y,w,h,r,g,b;
 t=getParameter("xx");
 x=Integer.parseInt(t);
 t=getParameter("yy");
 y=Integer.parseInt(t);
 t=getParameter("ww");
 w=Integer.parseInt(t);
 t=getParameter("hh");
 h=Integer.parseInt(t);
 t=getParameter("rr");
 r=Integer.parseInt(t);
 t=getParameter("gg");
 g=Integer.parseInt(t);
 t=getParameter("bb");
 b=Integer.parseInt(t);
 p.setColor(new Color(r,g,b));
 p.fillRect(x,y,w,h);

} }

<html>
<body>
<applet code="s09_02.class" width=400 height=400>
<param name="xx" value="25"><param name="yy" value="25">
<param name="ww" value="150"><param name="hh" value="150">
<param name="rr" value="0"><param name="gg" value="150">
<param name="bb" value="100">
</applet>
</body>
</html>


Also suggest me what changes should i make in this code so that code runs properly ??
Thanks...
4

2 に答える 2

3

public void actionPerformed(ActionEvent e){}を実装するときにコードを追加する必要がありますActionListner

ActionListnerであるinterfaceため、の抽象メソッドをオーバーライドする必要がありますActionListner

イベントを使用していない場合はimplements ActionListner、コードから を削除してください。

于 2014-04-03T04:04:28.620 に答える