为什么
public class Class1 extends Frame implements WindowListener,MouseListener
出错了
Class1 is not abstact and does not override abstract method mouse
接口的方法必须要实现
即使只是把方法放在那里 里面什么也不做
代码是这样的 看看有什么错的
import java.awt.*;
import java.awt.event.*;
public class class1 extends Frame implements WindowListener,MouseListener{
static class1 mw;
Panel pan1=new Panel();
Panel pan2=new Panel();
Panel pan3=new Panel();
Panel pan4=new Panel();
CardLayout layout=new CardLayout();
public static void main(String args[]){
mw.setpan1();
mw.setpan2();
mw.setpan3();
mw.setpan4();
mw.go();
}
public void go(){
mw=new class1("four layouts");
mw.setLayout(new GridLayout(2,2));
mw.add(pan1);
mw.add(pan2);
mw.add(pan3);
mw.add(pan4);
mw.addWindowListener(mw);
mw.setSize(400,400);
mw.setVisible(true);
}
class1(String str){
super(str);
}
public void setpan1(){
pan1.setLayout(new BorderLayout());
Button b1=new Button("North");
Button b2=new Button("South");
Button b3=new Button("East");
Button b4=new Button("Center");
Button b5=new Button("West");
pan1.add("North",b1);
pan1.add("South",b2);
pan1.add("East",b3);
pan1.add("Center",b4);
pan1.add("West",b5);
}
public void setpan2(){
pan2.setLayout(new GridLayout(2,2));
Button b1=new Button("1");
Button b2=new Button("2");
Button b3=new Button("3");
Button b4=new Button("4");
pan2.add(b1);
pan2.add(b2);
pan2.add(b3);
pan2.add(b4);
}
public void setpan3(){
pan3.setLayout(new FlowLayout());
Button b1=new Button("1");
Button b2=new Button("2");
Button b3=new Button("3");
pan3.add(b1);
pan3.add(b2);
pan3.add(b3);
pan3.setBackground(Color.red);
}
public void setpan4(){
pan4.setLayout(layout);
Button b1=new Button("the fist page");
b1.addMouseListener(this);
Label b2=new Label("the second page");
b2.addMouseListener(this);
pan4.add(b1,"b1");
pan4.add(b2,"b1");
}
public void windowClosing(WindowEvent e){
System.exit(1);
}
public void windowOpened(WindowEvent e){
}
public void windowIconified(WindowEvent e){
}
public void windowDeiconified(WindowEvent e){
}
public void windowClosed(WindowEvent e){
}
public void windowActivated(WindowEvent e){
}
public void windowDeactivated(WindowEvent e){
}
public void mouseClicked(MouseEvent e){
layout.next(pan4);
}
public void mouseEntered(MouseEvent e){
}
public void mouseExited(MouseEvent e){
}
public void mousePressde(MouseEvent e){
}
public void mouseReleased(MouseEvent e){
}
}
代码是这样的 看看有什么错的
import java.awt.*;
import java.awt.event.*;
public class class1 extends Frame implements WindowListener,MouseListener{
static class1 mw;
Panel pan1=new Panel();
Panel pan2=new Panel();
Panel pan3=new Panel();
Panel pan4=new Panel();
CardLayout layout=new CardLayout();
public static void main(String args[]){
mw.setpan1();
mw.setpan2();
mw.setpan3();
mw.setpan4();
mw.go();
}
public void go(){
mw=new class1("four layouts");
mw.setLayout(new GridLayout(2,2));
mw.add(pan1);
mw.add(pan2);
mw.add(pan3);
mw.add(pan4);
mw.addWindowListener(mw);
mw.setSize(400,400);
mw.setVisible(true);
}
class1(String str){
super(str);
}
public void setpan1(){
pan1.setLayout(new BorderLayout());
Button b1=new Button("North");
Button b2=new Button("South");
Button b3=new Button("East");
Button b4=new Button("Center");
Button b5=new Button("West");
pan1.add("North",b1);
pan1.add("South",b2);
pan1.add("East",b3);
pan1.add("Center",b4);
pan1.add("West",b5);
}
public void setpan2(){
pan2.setLayout(new GridLayout(2,2));
Button b1=new Button("1");
Button b2=new Button("2");
Button b3=new Button("3");
Button b4=new Button("4");
pan2.add(b1);
pan2.add(b2);
pan2.add(b3);
pan2.add(b4);
}
public void setpan3(){
pan3.setLayout(new FlowLayout());
Button b1=new Button("1");
Button b2=new Button("2");
Button b3=new Button("3");
pan3.add(b1);
pan3.add(b2);
pan3.add(b3);
pan3.setBackground(Color.red);
}
public void setpan4(){
pan4.setLayout(layout);
Button b1=new Button("the fist page");
b1.addMouseListener(this);
Label b2=new Label("the second page");
b2.addMouseListener(this);
pan4.add(b1,"b1");
pan4.add(b2,"b1");
}
public void windowClosing(WindowEvent e){
System.exit(1);
}
public void windowOpened(WindowEvent e){
}
public void windowIconified(WindowEvent e){
}
public void windowDeiconified(WindowEvent e){
}
public void windowClosed(WindowEvent e){
}
public void windowActivated(WindowEvent e){
}
public void windowDeactivated(WindowEvent e){
}
public void mouseClicked(MouseEvent e){
layout.next(pan4);
}
public void mouseEntered(MouseEvent e){
}
public void mouseExited(MouseEvent e){
}
public void mousePressde(MouseEvent e){
}
public void mouseReleased(MouseEvent e){
}
}