如何检测SWT Table的滚动条可见性变化
如何检测 Java SWT Table 的垂直 ScrollBar 何时变得可见?我需要这些信息来重新计算列的宽度。似乎滚动条上没有触发任何事件(除了选择)。
How can I detect when a Java SWT Table's vertical ScrollBar becomes visible? I need that information to recompute the columns' widths. Seems like no event (besides Selection) is ever fired on the ScrollBars.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您已经正确地发现,没有简单的方法可以检测
垂直 ScrollBar 何时可见
。无论如何,这里提供的解决方案是一种 hack。我正在使用此 SWT 代码段 计算表中的可见行。除此之外,我还使用
SWT Paint Event
。基本概念如下:
SWT Paint Event
>>>代码
>>输出
对于itemcount <可见行数
对于 itemcount >= 可见行数
注意- 如果您要使用绘制事件,请尝试在调用时保持最小计算量频繁地。
希望这会有所帮助。
I think you have correctly found out that there is no easy way of detecting
when the vertical ScrollBar is visible
. Anyway the solution here provided is kind of hack.I am using the concept presented in this SWT snippet compute the visible rows in a table. Along with that I am also using
SWT Paint Event
.The basic concept is like as follows:
SWT Paint Event
>> Code
>> Output
For itemcount < numberofvisible rows
For itemcount >= numberofvisible rows
Note- If you are going to use the paint event then try keep the calculations minimum as it is called frequently.
Hope this will help.
这对我有用:
This works for me:
我发现,在调整大小通知后,您可以获取可滚动的边界和客户区域之间的差异。任一维度的差异都表明存在滚动条。
I found that, upon the resize notification, you can take the difference between the bounds and the client area of a Scrollable. A difference in either dimension should suggest the presence of a scrollbar.