Java——JDialog不可移动
什么代码有助于使 JDialog
不可移动?我研究了两个选项:
setUndecorated(true);
,它可以工作,但会删除所有装饰。addComponentListener
并重写componentMoved()
方法,这会导致JDialog
在移动时随后调用induceEpilepticSeizure()
。
有什么想法吗?
What code will facilitate making a JDialog
unmovable? I've looked at two options:
setUndecorated(true);
which works but removes all the trimmings.addComponentListener
and overriding thecomponentMoved()
method, which causes theJDialog
to subsequently callinduceEpilepticSeizure()
upon moving.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的第一直觉是 - 你不能,除非你确实使用 setUndecorated(true)...你可以手动在那里放置一些装饰,但是,嗯,呃!
因此,如果您想要原生装饰,并且希望它不可移动,而又不会因使用组件侦听器而产生可怕的闪烁,我认为您不能。
您可以手动创建一个看起来像默认边框的边框...这是一个如何执行此操作的示例,尽管我故意使边框看起来像您整天看到的最丑陋的东西。您需要找到正确的 BorderFactory 调用组合来实现您想要做的事情。
My first instinct is - you can't unless you DO use setUndecorated(true)... You could manually put some trimmings there, but, well, UGH!
So if you want the native trimmings AND you want it immovable without the horrible flickering from using a component listener, I think you can't.
You could create a border manually that LOOKS like the default border...here's an example of how to do it, although I've intentionally made the border look like the ugliest thing you've seen all day. You'll need to find the right combination of BorderFactory calls to achieve what you want to do.