package DeskTop;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Note extends JFrame implements MouseListener,MouseMotionListener{
private JLabel iconLabel;
private JPanel firstpPanel;
private ImageIcon backIcon;
public Note() {
backdrop();
}
private void backdrop() {
//搭建背景,容器
setUndecorated(true);
backIcon = new ImageIcon("backdrop1.gif");
iconLabel = new JLabel(backIcon);
iconLabel.setBounds(0, 0,backIcon.getIconWidth(),backIcon.getIconHeight());
firstpPanel = (JPanel)this.getContentPane();
getLayeredPane().setLayout(null);
getLayeredPane().add(iconLabel, new Integer(Integer.MIN_VALUE));
firstpPanel.setOpaque(false);
//AWTUtilities.setWindowOpacity(this, 0.5f);
setSize(backIcon.getIconWidth(),backIcon.getIconHeight());
/*AWTUtilities.setWindowShape(this, new RoundRectangle2D.Double(
0.0D, 0.0D, this.getWidth(), this.getHeight(), 80.0D,
30.0D));*/
setLocation(80, 80);
setVisible(true);
addMouseListener(this);
addMouseMotionListener(this);
}
public static void main(String[] args) {
new Note();
}
Boolean tBoolean = false;
Point fPoint;
Point sPoint;
Point tPoint;
private void move() {
Double fx,fy;
Double sx,sy;
Double tx,ty;
fx = fPoint.getX(); fy = fPoint.getY();
sx = sPoint.getX(); sy = sPoint.getY();
tx = tPoint.getX(); ty = tPoint.getY();
fPoint.setLocation(fx+tx-sx, fy+ty-sy);
setLocation(fPoint);
}
public void mouseDragged(MouseEvent e) {
//tBoolean = true;
//System.out.println("ddddd");
tPoint = e.getPoint();
move();
}
public void mousePressed(MouseEvent e) {
fPoint = getLocation();
sPoint = e.getPoint();
}
public void mouseMoved(MouseEvent e) {
}
public void mouseClicked(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
}
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- igbc.cn 版权所有 湘ICP备2023023988号-5
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务