📄 movemouselistener.java
字号:
/* * 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -