Disable full window drag

别等时光非礼了梦想. 提交于 2020-01-06 08:43:31

问题


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?

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

Thanks for your help!


回答1:


Sorry for the my bad english. Try this:

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

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.




回答2:


You should test that on windows as I think that's a mac feature. You can, in general click anywhere in the frame to drag an app about. What's your target deployment platform? Maybe you can put another panel in it and set that to non-opague. maybe this will help?



来源:https://stackoverflow.com/questions/5272358/disable-full-window-drag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!