movemouselistener.java
来自「mymp3的运行程序的源代码」· Java 代码 · 共 64 行
JAVA
64 行
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package mymp3.pp;import java.awt.Component;import java.awt.Point;import java.awt.event.MouseEvent;import java.awt.event.MouseListener;import java.awt.event.MouseMotionListener;/** * * @author huliqing */public class MoveMouseListener implements MouseListener, MouseMotionListener { Component target; Point pMouse; Point pFrame; public MoveMouseListener(Component target) { this.target = target; } public void mouseClicked(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); } public void mousePressed(MouseEvent e) { this.pMouse = e.getLocationOnScreen(); this.pFrame = this.target.getLocation(); } public void mouseReleased(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); } public void mouseEntered(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); } public void mouseExited(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); } public void mouseDragged(MouseEvent e) { Point current = e.getLocationOnScreen(); Point offset = new Point ( (int) current.getX() - (int) pMouse.getX(), (int) current.getY() - (int) pMouse.getY() ); target.setLocation(new Point( (int) (pFrame.getX() + offset.getX()), (int) (pFrame.getY() + offset.getY()) )); } public void mouseMoved(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?