| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 991 人关注过本帖
标题:怎么错了
只看楼主 加入收藏
fgh1026
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2006-11-30
收藏
 问题点数:0 回复次数:10 
怎么错了

为什么
public class Class1 extends Frame implements WindowListener,MouseListener


出错了

Class1 is not abstact and does not override abstract method mouse



搜索更多相关主题的帖子: abstract public method 
2007-01-12 13:14
海狂
Rank: 1
等 级:新手上路
威 望:1
帖 子:234
专家分:0
注 册:2006-12-26
收藏
得分:0 

接口的方法必须要实现
即使只是把方法放在那里 里面什么也不做


2007-01-12 13:24
fgh1026
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2006-11-30
收藏
得分:0 

代码是这样的 看看有什么错的


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){
}
}



2007-01-12 13:36
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
收藏
得分:0 
以下是引用fgh1026在2007-1-12 13:36:26的发言:

代码是这样的 看看有什么错的


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){
}
}




可惜不是你,陪我到最后
2007-01-12 13:41
fgh1026
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2006-11-30
收藏
得分:0 

还是


和原来的一样

千里

你在看看

2007-01-12 13:49
海狂
Rank: 1
等 级:新手上路
威 望:1
帖 子:234
专家分:0
注 册:2006-12-26
收藏
得分:0 
千里给你标出错误了 mousePressde??
是mousePressed

2007-01-12 14:42
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
收藏
得分:0 
我服了楼主

可惜不是你,陪我到最后
2007-01-12 15:15
fgh1026
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2006-11-30
收藏
得分:0 
惭愧呀
2007-01-12 20:32
wuzhong
Rank: 1
等 级:新手上路
帖 子:233
专家分:0
注 册:2006-10-23
收藏
得分:0 

我也服了楼主了,有我当年的犯错误的影子了.呵呵.这个平时多注意一点,以后熟悉了,自然就知道错在什么地方了.


2007-01-12 20:38
wuzhong
Rank: 1
等 级:新手上路
帖 子:233
专家分:0
注 册:2006-10-23
收藏
得分:0 
刚才把楼主的代码调试了,eclipse说不对哦,说是空指针.
修改了一下:
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[]){
Class1 mw = new Class1("我的方格");
mw.setpan1();
mw.setpan2();
mw.setpan3();
mw.setpan4();
mw.go();
}

//set the main window formate
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(this);//mw
mw.setSize(400,400);
mw.setVisible(true);
}

public Class1 (String str){
super(str);
}

//set panel format
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);
}
//set panel2 formate
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");


}

//set window actions
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);

}
//set mouse action
public void mouseEntered(MouseEvent e){
}
public void mouseExited(MouseEvent e){
}
public void mousePressed(MouseEvent e){
}
public void mouseReleased(MouseEvent e){
}


}

2007-01-12 20:59
快速回复:怎么错了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.083393 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved