⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testmouseinterface.java

📁 几个小东西呵呵 刚学的 agadgethrtjhsghtyw4tewert
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
public class TestMouseInterface implements WindowListener,MouseMotionListener 
{
    Frame myframe;
    public void display()
   {
    myframe=new Frame("myframe");
    myframe.setLocation(400,300);
    myframe.setSize(400,300);
    myframe.setBackground(Color.lightGray);
    myframe.setVisible(true);
    myframe.addWindowListener(this); 
    myframe.addMouseMotionListener(this);
    }
    
    public static void main(String args[])
   {
    TestMouseInterface a=new TestMouseInterface();
    a.display(); 
   } 

 public void windowClosing(WindowEvent e)
  {
    System.exit(0);
  }
  
  public  void windowOpened(WindowEvent e)
 {}
  public  void windowClosed(WindowEvent e)
 {}
 public  void windowIconified(WindowEvent e)
 {}
 public  void windowDeiconified(WindowEvent e)
{}
 public  void windowActivated(WindowEvent e)
{}
 public  void windowDeactivated(WindowEvent e)
{}

 public void mouseDragged(MouseEvent e)
 {
  }
public void mouseMoved(MouseEvent e)
 {
 	int i,x,y;
     for(i=0;i<=10;i++)
      {
       Frame yframe=new Frame("yframe");
       x=(int) (Math.random()*800);
       y=(int) (Math.random()*600);
       System.out.println(x);
       System.out.println(y);
       yframe.setLocation(x,y);
       yframe.setSize(90/(i+1),90/(i+1));
       yframe.setBackground(Color.lightGray);
       yframe.setVisible(true);
       myframe.setVisible(false);
       yframe.addWindowListener(this); 
       yframe.addMouseMotionListener(this);
      } 
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -