SWT检查外壳是否超过屏幕边界
我有一个按钮在我的应用程序中打开外壳,该按钮显示了许多复选框,以及底部的2个按钮。问题在于,由于高度太大,它可能会被切断。
我想要的解决方案是将外壳的内容添加到滚动式复合材料中,这是行不通的,因为外壳只是高度扩展,因此复合式的滚动条无需做任何事情。
我认为最好的方法是计算外壳是否超过屏幕界限,但我不明白其坐标如何真正起作用。 Shell的父是外壳,因此shell :: getBounds()
应该返回坐标相对于显示相对于Monitor (在这种情况下,我可以通过shell :: getMonitor()
)获得。
我该怎么做?
I have a button that opens a shell in my application, which displays a number of checkboxes, along with 2 buttons at the bottom. The problem is that it can get cut off due to its height being too big.
The solution I want is to add the contents of the shell to a ScrollableComposite, which doesn't work, because the shell just expands in height, so the composite's scrollbars don't do anything.
I figured the best way would be to calculate if the shell exceeds the screen bounds, but I don't understand how its coordinates really work. The shell's parent is a shell, so Shell::getBounds()
is supposed to return the coordinates relative to the display, but I think I need the shell's bounds relative to the monitor (which I can get through Shell::getMonitor()
) in this case.
How can I do this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需根据监视器的大小而不是边界设置外壳尺寸即可。
这是Eclipse启动配置对话框用来确保其不太大的内容:
Just set the shell size based on the monitor size rather than the bounds.
This is what the Eclipse Launch Configuration Dialog uses to make sure it is not too big: