程序是在鼠标进入btn1时后台打印出一段话!可是我的程序怎么都通不过编译,想了半天也没有解决!
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class mouseTest extends JFrame {
JPanel jp;
BorderLayout br;
/*
* 添加Button
*/
JButton btn1;
JButton btn2;
public void mouseTest()
{
this.setTitle("123");
br = new BorderLayout();
jp = new JPanel();
btn1 = new JButton("123");
btn2 = new JButton("456");
jp.add(btn1,java.awt.BorderLayout.NORTH);
btn1.addMouseListener(new btn1());//添加事件
this.getContentPane().add(jp);
setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(500,600);
setVisible(true);
}
class btn1 implements MouseListener
{
public void mouseEntered(MouseEvent e)
{
System.out.println("324");
}
}
public static void main(String[] args) {
mouseTest mt = new mouseTest();
mt.mouseTest();
}
}