1

SWT Text コントロールをグループ内で希望どおりにレイアウトするのに問題があります。具体的には、verticalSpan渡されたGridDataを GUI アセットに反映させるのに苦労しています。以下の例では、正しく表示できない 3 つのコントロールはdescriptionTextdefaultActionText、および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 ) );

Translation Controls (幅 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 );

説明/アクション コントロール (期待どおりに機能しないため、すべての高さを 1 ではなく 3 にしたい):

    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の外観は次のとおりです。

ここに画像の説明を入力

4

1 に答える 1

-1

translationTextとの動作の違いdefaultActionTextは非常に簡単に説明できます。

両方に 3 行にまたがるように指示しました。ただし、 のこれら 3 つの行の高さは他の( 、、 )translationTextによって定義されますが、 の場合はそうではありません。これら 3 つの行には、他のウィジェットはありません ( を除く)。したがって、高さは必要な高さに設定されます。WidgetshostnameTextinstanceLabelinstanceTextdefaultActionTextdefaultReportActionText

heightHintの を設定することで、この高さを手動で増やすことができますGridData

GridData data = new GridData( SWT.FILL, SWT.FILL, true, false, 1, 3 );
data.heightHint = 80;

defaultActionText.setLayoutData(data);
defaultReportActionText.setLayoutData(data);

結果はここで見ることができます:

ここに画像の説明を入力

高さのより正確な結果を得るには、次を使用できます。

data.heightHint = hostnameText.computeSize(SWT.DEFAULT, SWT.DEFAULT).y
                + instanceLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y
                + instanceText.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
于 2012-09-17T16:53:24.317 に答える