禁用全窗口拖动 [英] Disable full window drag

查看:135
本文介绍了禁用全窗口拖动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 AWTUtilities.setWindowOpaque(this,false); 使JFrame的背景透明时,可以通过将JFrame拖动到窗口。我的问题是,我有要在此Frame上拖放的对象,但是当JFrame移动时,当我尝试拖动对象时,无法将其拖放到其他位置。
有什么方法可以解决这个问题吗?

when I use AWTUtilities.setWindowOpaque(this, false); to make my JFrames' background transparent, you can change the location of my JFrame by dragging it anywhere in the window. My problem is, that I have Objects I want to use for drag and drop on this Frame, but when the JFrame moves when I try to drag an object its impossible to drop it anywhere else. Is there any way to solve this problem?

顺便说一句,我在Mac上使用Mac OS 10.6.6

By the way, I am on Mac using Mac OS 10.6.6

谢谢您的帮助!

推荐答案

对不起,我的英语不好。
尝试以下操作:

Sorry for the my bad english. Try this:

setUndecorated(true); 
AWTUtilities.setWindowOpaque(this, false); 
getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE); 

默认情况下,setWindowOpaque函数将此客户端属性设置为true。但是此客户端属性使窗口中的每个组件都可以拖动。

By default the setWindowOpaque function set this client property as true. But this client property makes every component within your window draggable.

现在,您必须自己制作拖动代码。

Now you have to make the drag code by yourself.

这篇关于禁用全窗口拖动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆