mousemotionlistener接口包含哪些方法
1个回答
展开全部
当实现接口时,要实现其所有的方法。其中用不到的方法,实现为空方法。代码修改如下:
import java.awt.*;
import java.awt.event.*;
public class TestMouse implements MouseListener,MouseMotionListener{
public static void main (String args[ ]){
TestMouse t=new TestMouse( );
t.go( );}void go(){Frame f = new Frame("fang");
f.setSize(208,230);
f.addMouseListener(this);
f.addMouseMotionListener(this);
f.setVisible(true);}//implement methods in MouseMotionListener
public void mouseMoved(MouseEvent ev){
int x1=ev.getX();
int y1=ev.getY();
System.out.print("mousemoved"+" "+x1+" "+y1);}public void mouseDragged(MouseEvent ev){}
//implement methods in MouseListener
public void mouseClicked(MouseEvent ev){}
public void mousePressed(MouseEvent ev){}
public void mouseReleased(MouseEvent ev){}
public void mouseEntered(MouseEvent ev){}} 接口方法没有重载
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询