很菜的问题,谢谢大家帮忙。

jackedfang jackedfang 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
package awttest;
import java.awt.*;
import java.awt.event.*;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/

public class TestCard implements MouseListener{
Panel p1,p2;
Label l1,l2;
Button b1,b2;
CardLayout mycard;
Frame f;
public static void main(String[] args) {
TestCard ct=new TestCard();
ct.init();
}
public void init(){
f=new Frame ("card test");
mycard=new CardLayout();
f.setLayout(mycard);
p1=new Panel();
p2=new Panel();
l1=new Label("this is the first panel");
b1=new Button("show page2");
b1.addMouseListener(this) ;
p1.setBackground(Color.yellow ) ;
p1.add(l1);
p1.add(b1) ;
l2=new Label("this is the second panel");
b2=new Button("show page1");
b2.addMouseListener(this);
p2.setBackground(Color.green ) ;
p2.add(l2) ;
p2.add(b2) ;
f.add(p1,"first") ;
f.add(p2,"second");
mycard.show(f,"first");
f.setSize(200,200) ;
f.setVisible(true) ;
}
public void mouseclicked(MouseEvent e){
mycard.next(f);
}
public void mouseEntered(MouseEvent e){}
public void mouseEvent(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}

}

错误提示是:Class awttest.TestCard should be declared abstract,it dose not define method mouseExited(java.awt.event.MouseEvent)in interface java awt.event.MouseListener at line 14
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
jackedfang
Java SE 62,621 成员 307,251 内容