SashFormとは何ですか?

SWTでは、SashFormはGroupと似ていますが、便利な機能が追加されています。実行時の環境でコントロールのサイズを調整することができます。 SashFormは、子ウィジェット(ボタン、ラベル、テキスト…​)の間に移動可能な線を作成することにより、この機能を提供します。ユーザーが「線」をドラッグすると、1つのウィジェットサイズが拡大され、他のウィジェットサイズが縮小されます。

SashFormウィジェットは2つのスタイルをサポートしています。

{空} 1)SWT.SWT.HORIZONTAL 2)SWT.VERTICAL

SashFormウィジェットを作成するには?

ここでは、4つのボタンウィジェットを作成し、SashFormにHORIZONTALおよびVERTICALスタイルでリンクする方法を示します。

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class SWTSashForm
{
    public static void main (String[]args) {
        Display display = new Display ();
        Shell shell = new Shell(display);
        shell.setText("SWT SashForm Example");

        shell.setLayout(new FillLayout());

       //Create the SashForm with HORIZONTAL
        SashForm sashForm = new SashForm(shell, SWT.HORIZONTAL);
        new Button(sashForm, SWT.PUSH).setText("Left");
        new Button(sashForm, SWT.PUSH).setText("Right");

       //Create the SashForm with VERTICAL
        SashForm sashForm2 = new SashForm(shell, SWT.VERTICAL);
        new Button(sashForm2, SWT.PUSH).setText("Up");
        new Button(sashForm2, SWT.PUSH).setText("Down");

        shell.open();

        while (!shell.isDisposed ()) {
            if (!display.readAndDispatch ()) display.sleep ();
        }
        display.dispose ();
    }

}


image、title = "swt-sash-1"


image、title = "swt-sash-2"