×

Loading...

java problem

here is the application of java.when it compile ,what will be complained by compiler?Why?what's the deference between using the ActionListener and MouseMotionListener?
How to apply the function that listen the mouse motion event by the button?

why?
import java.awt.event.*;
import javax.swing.*;

public class A extends JPanel{
JButton jb=new JBUtton("test");
JTextField txt=new JTextField(20);
jb.addMouseMotionListener(new MouseMotionListener(){
public void mouseDrapped(MouseEvent e){}
public void mouseMoved9MouseEvent e){
txt.setText("Done!");
}
});
public static void main(String[] args){
JFrame frame=new JFrame();
frame.getContentPane().add(new A());
frame.setSize(300,200);
frame.setVisible(true);
}
}
Report

Replies, comments and Discussions: