如何在不禁用 SWT 中的最小化、最大化和关闭按钮的情况下禁用 shell

How to disable a shell without disabling minimize, maximize and close button in SWT

我正在尝试使用

在 SWT 中禁用 shell
sell.setEnabled(false);

这工作正常,我想阻止用户执行操作,但同时我想让他最小化 shell。问题是 setEnabled(false) 将禁用整个 shell.

你有什么想法吗?

我猜你想禁用 shell 的内容。那你为什么不根据需要在shell和disable/enable中添加一个容器(Composite)作为主要内容呢?这不会影响 shell,因此,最小化按钮将继续工作。

final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final Composite composite = new Composite(shell, SWT.NONE);
composite.setEnabled(false);

不是禁用 Shell 本身,而是禁用它包含的控件。像这样:

Control[] children = shell.getChildren();
for( Control control : children ) {
  control.setEnabled( false );
}