日期:2014-05-20 浏览次数:20969 次
package net.csdn.www; import java.awt.Point; import java.awt.event.MouseEvent; import javax.swing.JFrame; import javax.swing.event.MouseInputAdapter; public class RemoveTitle { public static void main(String[] args) { new NoTitleWindow(); } } class NoTitleWindow extends JFrame { public NoTitleWindow() { setUndecorated(true); setBounds(100, 100, 100, 100); setVisible(true); MouseOperate mo = new MouseOperate(); addMouseListener(mo); addMouseMotionListener(mo); } private class MouseOperate extends MouseInputAdapter { private Point point1; public void mousePressed(MouseEvent e) { point1 = e.getPoint(); } public void mouseDragged(MouseEvent e) { Point point2 = new Point(); point2 = e.getPoint(); int dx = point2.x - point1.x; int dy = point2.y - point1.y; int x = getX(); int y = getY(); setLocation(x+dx,y+dy); } } }
------解决方案--------------------
加这条语句
System.exit(0);
------解决方案--------------------