瑞星卡卡安全论坛技术交流区系统软件 报了4个错,实在是找不出了,请帮帮忙,谢谢!(java)

1   1  /  1  页   跳转

报了4个错,实在是找不出了,请帮帮忙,谢谢!(java)

报了4个错,实在是找不出了,请帮帮忙,谢谢!(java)

如题,看不懂错误的解释,望高手不厌其烦的能为我解说一下,谢谢!在线等
package A;
import java.awt.*;
import javax.swing.*;
import java.applet.*;
import java.awt.event.*;
class Addbutton extends JPanel
{
    JButton bRed;
    JButton bGreen;
    JButton bBlue;
    public Addbutton()
    {
        JButton bRed=new JButton("红");
        JButton bGreen=new JButton("绿");
        JButton bBlue=new JButton("蓝");
        MyListener1 listener1=new MyListener1();
        bRed.addActionListener(listener1);
        MyListener2 listener2=new MyListener2();
        bGreen.addActionListener(listener2);
        MyListener3 listener3=new MyListener3();
        bBlue.addActionListener(listener3);
        this.setLayout(new FlowLayout());
        this.add(bRed);
        this.add(bGreen);
        this.add(bBlue);
    }
    private class MyListener1 implements ActionListener
    {
        public void actionperformed(ActionEvent e)
        {
            setBackground(Color.red);
            //Repain();
        }
    }
    private class MyListener2 implements ActionListener
    {
        public void actionperformed(ActionEvent e)
        {
            setBackground(Color.green);
            //rePain();
        }
    }
    private class MyListener3 implements ActionListener
    {
        public void actionperformed(ActionEvent e)
        {
            setBackground(Color.blue);
            //repain();
        }
    }
}
public class A extends JFrame
{
    public A(String tilte)
    {
        this.setTitle(title);//super(title);
        Container contpane=this.getContentPane();
        Addbutton adb=new Addbutton();
        contpane.add(adb);
        this.setSize(300,300);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    public static void main(String[]args)
    {
        A frame=new A("窗体测试");
    }
}
--------------------配置: <默认>--------------------
G:\learn space\Java\两个窗体\A.java:27: A.Addbutton.MyListener1 不是抽象的,并且未覆盖 java.awt.event.ActionListener 中的抽象方法 actionPerformed(java.awt.event.ActionEvent)
        private class MyListener1 implements ActionListener
                ^
G:\learn space\Java\两个窗体\A.java:35: A.Addbutton.MyListener2 不是抽象的,并且未覆盖 java.awt.event.ActionListener 中的抽象方法 actionPerformed(java.awt.event.ActionEvent)
        private class MyListener2 implements ActionListener
                ^
G:\learn space\Java\两个窗体\A.java:43: A.Addbutton.MyListener3 不是抽象的,并且未覆盖 java.awt.event.ActionListener 中的抽象方法 actionPerformed(java.awt.event.ActionEvent)
        private class MyListener3 implements ActionListener
                ^
G:\learn space\Java\两个窗体\A.java:56: title 在 java.awt.Frame 中不是公共的;无法从外部软件包中对其进行访问
                this.setTitle(title);//super(title);
                              ^
4 错误
处理已完成
最后编辑2006-11-09 15:49:29
分享到:
gototop
 

前三个是ActionListener接口actionPerformed方法没有实现(空实现也是实现)
最后一个是拼写错误 把title 拼成tilte

-------------------------------------------
package com.myTest;

import java.awt.*;
import javax.swing.*;
import java.applet.*;
import java.awt.event.*;

class Addbutton extends JPanel {
JButton bRed;

JButton bGreen;

JButton bBlue;

public Addbutton() {
JButton bRed = new JButton("红");
JButton bGreen = new JButton("绿");
JButton bBlue = new JButton("蓝");
MyListener1 listener1 = new MyListener1();
bRed.addActionListener(listener1);
MyListener2 listener2 = new MyListener2();
bGreen.addActionListener(listener2);
MyListener3 listener3 = new MyListener3();
bBlue.addActionListener(listener3);
this.setLayout(new FlowLayout());
this.add(bRed);
this.add(bGreen);
this.add(bBlue);
}

private class MyListener1 implements ActionListener {
public void actionperformed(ActionEvent e) {
setBackground(Color.red);
// Repain();
}

public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub

}
}

private class MyListener2 implements ActionListener {
public void actionperformed(ActionEvent e) {
setBackground(Color.green);
// rePain();
}

public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub

}
}

private class MyListener3 implements ActionListener {
public void actionperformed(ActionEvent e) {
setBackground(Color.blue);
// repain();
}

public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub

}
}
}

public class A extends JFrame {
public A(String title) {

this.setTitle(title);// super(title);
Container contpane = this.getContentPane();
Addbutton adb = new Addbutton();
contpane.add(adb);
this.setSize(300, 300);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public static void main(String[] args) {
A frame = new A("窗体测试");
}
}
gototop
 
1   1  /  1  页   跳转
页面顶部
Powered by Discuz!NT