1
我已經使用JFace創建了Dialog
並將其設置爲使用SWT.RESIZE
調整大小。 但是,它允許用戶將其調整到只有標題欄可見的0行。將JFaces對話框調整爲零行
有沒有一種方法可以限制用戶調整到只有一定數量的行?
我已經使用JFace創建了Dialog
並將其設置爲使用SWT.RESIZE
調整大小。 但是,它允許用戶將其調整到只有標題欄可見的0行。將JFaces對話框調整爲零行
有沒有一種方法可以限制用戶調整到只有一定數量的行?
使用Shell#setMinimumSize(int, int)
這樣的:
public class MyDialog extends Dialog
{
public static void main(String[] args)
{
new MyDialog(new Shell()).open();
}
public MyDialog(Shell parentShell)
{
super(parentShell);
setShellStyle(SWT.RESIZE | SWT.DIALOG_TRIM);
}
@Override
protected Control createDialogArea(Composite parent)
{
Composite container = (Composite) super.createDialogArea(parent);
getShell().setMinimumSize(400, 300);
new Button(container, SWT.PUSH).setText("Some content here");
return container;
}
}
這將限制用戶從減少的400寬度下面的尺寸和300
的高度保持不同的屏幕分辨率記住,雖然,因爲強制執行的最小尺寸可能會超過可用屏幕尺寸...