简体   繁体   English

swt shell 和组件的最小尺寸

[英]Minimum size of swt shell and components

How can I set a minimum size of the shell in swt?如何在 swt 中设置 shell 的最小尺寸? For example I have added a search field in my shell but I can shrink the shell almost completely and then the search field isn't completely visible.例如,我在 shell 中添加了一个搜索字段,但我可以几乎完全缩小 shell,然后搜索字段不完全可见。 Can I change a property of the search field to stop resizing if it would be unseen?如果看不见,我可以更改搜索字段的属性以停止调整大小吗?

No, there isn't any property or anything like that to prevent the resizing.不,没有任何属性或类似的东西可以阻止调整大小。

About the only thing you can do is add a resize listener to the shell and stop the resize if the shell is too small:您唯一能做的就是向 shell 添加一个调整大小的侦听器,如果 shell 太小,则停止调整大小:

shell.addListener(SWT.Resize, event -> {
  Shell eventShell = (Shell)event.widget;

  Point size = eventShell.getSize();

  if (size.x < 100 || size.y < 100)
   {
     // Stop the resize event
     event.doit = false;
   }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM