driver.java
来自「Java程序设计(美) David D. Riley著 机械工业出版社 书籍配套」· Java 代码 · 共 33 行
JAVA
33 行
import javax.swing.JFrame;import java.awt.event.*;/** Mouse Motion Program Driver (Figure D.17) * Author: David D. Riley * Date: January, 2005 */public class Driver implements MouseMotionListener { private JFrame window; private Rectangle mouser; public Driver(){ window = new JFrame("Mouse Motion"); window.setBounds(10, 10, 200, 200); window.getContentPane().setLayout( null ); mouser = new Rectangle( 10, 10, 100, 100 ); mouser.addMouseMotionListener( this ); window.getContentPane().add( mouser ); mouser.repaint(); window.setVisible(true); } public void mouseDragged( MouseEvent e ) { System.out.println( "Mouse dragged event" ); } public void mouseMoved( MouseEvent e ) { System.out.println( "Mouse moved event" ); System.out.println( " x: " + e.getX() ); System.out.println( " y: " + e.getY() ); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?