很菜的问题,谢谢大家帮忙。
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
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
...全文
相关推荐
人、狼、羊、菜 过河问题
一个人带着一匹狼、一只羊和一筐白菜要自己划船从河的北岸过河到南岸。人不在时,狼会吃羊,羊会吃白菜。只有人会划船并且每次只能带一个对象过河。此程序解决如何过河
狼羊菜渡河问题
【引言】这两天读司守奎《建模算法与应用》读到一个非常有意思的问题,就是小学时我们都玩过的一道奥赛题,狼羊菜渡河问题。 【问题🐺🐏】某人带狼、羊和蔬菜渡河,一小船除需要人划外,每次只能载一物过河。而当人不在场时,狼会吃羊,羊会吃菜。问此人应如何渡河? 【最开始思路】小学奥赛题是怎么解的来着...,放弃那种想法,还真的想不到,看看答案,觉得好神奇,居然可以跟我们学过的图论相关联。 【思路】 我们用一个四维向量来表示状态,第一个分量表示人,第二个分量表示狼,第三个分量表示羊,第四个分量表示蔬菜。它们的状态
经典的狼羊菜过河问题
最经典的狼羊菜过河问题,代码的实现。 使用C++语言实现。 属于人工智能范畴内。
易语言菜票问题
易语言菜票问题源码,菜票问题
易语言菜票问题源码-易语言
易语言菜票问题源码


Java SE
