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

📄 example4_11.java

📁 书中的例题
💻 JAVA
字号:
import java.awt.* ;
import java.awt.event.*;
public class Example4_11
{
  private Frame win;
  private TextField text;
  
  public Example4_11()
  {
    win=new Frame("匿名类");
    text=new TextField(30);
   }

  public void inFrame()
  {
    Label label=new Label("点击并拖曳鼠标");
    win.add(label,BorderLayout.NORTH);
    win.add(text,BorderLayout.SOUTH);
     /*匿名类开始,使用鼠标运动适配器*/
	win.addMouseMotionListener(new MouseMotionAdapter()
  {
     public void mouseDragged(MouseEvent e)
	  {
       String s="Mouse dragging: x="+e.getX()+"  Y="+e.getY();
       text.setText(s);
	  }
    } );/*匿名类结束*/
	
	win.setSize(300,200);
    win.setVisible(true); 
   }

  public static void main(String args[]) {
    Example4_11 w=new Example4_11();
    w.inFrame();
   }
  }

⌨️ 快捷键说明

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