我在让 SWT 文本控件按照我希望它们在组中的布局方式时遇到问题。具体来说,我很难将verticalSpan
传递给GridData
反映在 GUI 资产中。在下面的示例中,我无法正确显示的 3 个控件是descriptionText
、defaultActionText
和defaultReportActionText
,但translationText
显示正确。我不确定我在这里做错了什么,所以我很感激任何反馈!
团体:
paramsFieldComposite = new Group( upperRightComposite, SWT.BORDER );
// TODO: Change group to composite and remove .setText()
paramsFieldComposite.setText( "paramsFieldComposite" );
paramsFieldComposite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 1 ) );
paramsFieldComposite.setLayout( new GridLayout( 2, true ) );
翻译控件(按我的预期工作,宽度为 1,高度为 3):
Label hostnameLabel = new Label( paramsFieldComposite, SWT.NONE );
hostnameLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false, 1, 1 ) );
hostnameLabel.setText( configResourceBundle.geti18nDisplay( "HostnameLabel" ) );
Label translationLabel = new Label( paramsFieldComposite, SWT.NONE );
translationLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 1, 1 ) );
translationLabel.setText( configResourceBundle.geti18nDisplay( "TranslationLabel" ) );
hostnameText = new TextControl( paramsFieldComposite, SWT.BORDER );
hostnameText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 1, 1 ) );
hostnameText.setEditable( true );
translationText = new TextControl( paramsFieldComposite, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP );
translationText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 1, 3 ) );
translationText.setEditable( true );
描述/操作控件(没有像我期望的那样工作,我希望它们的高度都为 3 而不是 1):
Label descriptionLabel = new Label( paramsFieldComposite, SWT.NONE );
descriptionLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 2, 1 ) );
descriptionLabel.setText( configResourceBundle.geti18nDisplay( "DescriptionLabel" ) );
descriptionText = new TextControl( paramsFieldComposite, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI );
descriptionText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 2, 3 ) );
descriptionText.setEditable( true );
Label defaultActionLabel = new Label( paramsFieldComposite, SWT.NONE );
defaultActionLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 1, 1 ) );
defaultActionLabel.setText( configResourceBundle.geti18nDisplay( "DefaultActionLabel" ) );
Label defaultReportActionLabel = new Label( paramsFieldComposite, SWT.NONE );
defaultReportActionLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 1, 1 ) );
defaultReportActionLabel.setText( configResourceBundle.geti18nDisplay( "DefaultReportActionLabel" ) );
defaultActionText = new TextControl( paramsFieldComposite, SWT.BORDER | SWT.V_SCROLL );
defaultActionText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 1, 3 ) );
defaultActionText.setEditable( true );
defaultReportActionText = new TextControl( paramsFieldComposite, SWT.BORDER | SWT.V_SCROLL );
defaultReportActionText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 1, 3 ) );
defaultReportActionText.setEditable( true );
这是 GUI 的样子。