日期:2014-05-20  浏览次数:20703 次

挺有趣的东东


[code=Java][/code]import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;


public class CatchMe extends JFrame{

public CatchMe(){
setLayout(new GridLayout(2,2));
  JLabel t=new JLabel(" catch me!");
add(t);
setLocationRelativeTo(null);
setSize(200, 100);
setVisible(true);
setDefaultCloseOperation(3);
addMouseListener(new MouseAdapter(){
public void mouseEntered(MouseEvent e){
int x=getX();
int y=getY();
setLocation((x+300)%800, (y+200)%600);
   

}

});

}
   
public static void main(String[] args){
CatchMe ha=new CatchMe();
}


}


------解决方案--------------------
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
这样好了,即使逮住了也关不掉,呵呵