java隐藏标题栏并且可以移动例子_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > java隐藏标题栏并且可以移动例子

java隐藏标题栏并且可以移动例子

 2011/8/10 17:20:54  lucene3212  http://lucene3212.iteye.com  我要评论(0)
  • 摘要:importjava.awt.event.mouseadapter;importjava.awt.event.mousemotionlistener;importjava.awt.borderlayout;importjava.awt.component;importjava.awt.point;importjava.awt.event.actionevent;importjava.awt.event.actionlistener;importjava.awt.event.mouseevent
  • 标签:例子 Java 标题
   
import java.awt.event.mouseadapter;import java.awt.event.mousemotionlistener;import java.awt.borderlayout;import java.awt.component;import java.awt.point;import java.awt.event.actionevent;import java.awt.event.actionlistener;import java.awt.event.mouseevent;import javax.swing.borderfactory;import javax.swing.jbutton;import javax.swing.jframe;import javax.swing.border.bevelborder;public class easymove extends mouseadapter implements mousemotionlistener {	private point offset;	private component host;	public static void main(string[] args) {		jframe frm = new jframe("easymove demo.");		frm.setdefaultcloseoperation(jframe.exit_on_close);		frm.setsize(300, 300);		frm.setundecorated(true);// 影藏边框		frm.getrootpane().setborder(				borderfactory.createbevelborder(bevelborder.raised));		new easymove().install(frm);		jbutton exit = new jbutton("exit");		exit.addactionlistener(new actionlistener() {			public void actionperformed(actionevent e) {				system.exit(0);			}		});		frm.getcontentpane().add(exit, borderlayout.south);		frm.setvisible(true);	}	public synchronized void install(component comp) {		uninstall();		host = comp;		host.addmouselistener(this);		host.addmousemotionlistener(this);	}	public synchronized void uninstall() {		if (host != null) {			host.removemouselistener(this);			host.removemousemotionlistener(this);			host = null;		}	}	public void mousepressed(mouseevent e) {		if (e.getsource() == host)			offset = e.getpoint();	}	public void mousedragged(mouseevent e) {		if (e.getsource() != host)			return;		final int x = host.getx();		final int y = host.gety();		final point lastat = e.getpoint();		host.setlocation(x + lastat.x - offset.x, y + lastat.y - offset.y);	}	public void mousemoved(mouseevent e) {	}}
??
java swing:http://www.java2s.com/code/java/swing-jfc/catalogswing-jfc.htm
 
发表评论
用户名: 匿名