0

私は Google の WindowBuilder を使用して、Eclipse でデスクトップ Java/SWT アプリケーション用の UI を作成しています。Mac OS X を使用しています。

私はこの単純なクラスを持っています(明確にするためにインポートを削除しました):

public class CustomersTab extends Composite {
    CustomersList mCustomersList;
    CustomerBadge mCustomerBadge;
    private final Table mtable;

    public CustomersTab(final Composite parent, final int style) {
        super(parent, style);
        setLayout(new GridLayout(3, false));

        final Composite leftPanel = new Composite(this, SWT.NONE);
        leftPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        leftPanel.setLayout(new GridLayout(1, false));

        final Label lblRerchercher = new Label(leftPanel, SWT.NONE);
        lblRerchercher.setFont(SWTResourceManager.getFont("Lucida Grande", 13, SWT.BOLD | SWT.ITALIC));
        lblRerchercher.setText("Clients");
        mCustomersList = new CustomersList(leftPanel, SWT.NONE);
        mCustomersList.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1));

        final Label label = new Label(this, SWT.SEPARATOR | SWT.VERTICAL);
        label.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1));

        final Composite rightPanel = new Composite(this, SWT.NONE);
        rightPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
        rightPanel.setLayout(new GridLayout(1, false));

        mCustomerBadge = new CustomerBadge(rightPanel, SWT.NONE);
        mCustomerBadge.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

        final Label label_2 = new Label(rightPanel, SWT.NONE);
        label_2.setText("Détails");
        label_2.setFont(SWTResourceManager.getFont("Lucida Grande", 13, SWT.BOLD | SWT.ITALIC));

        mtable = new Table(rightPanel, SWT.BORDER | SWT.FULL_SELECTION);
        mtable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        mtable.setHeaderVisible(true);
        mtable.setLinesVisible(true);

        final Label label_1 = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
        label_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        new Label(this, SWT.NONE);

        final Label label_3 = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
        label_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

        final Button btnNewButton = new Button(this, SWT.NONE);
        btnNewButton.setImage(SWTResourceManager.getImage(CustomersTab.class, "/img/user_add.png"));
        btnNewButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
        btnNewButton.setText("Nouveau client");
        new Label(this, SWT.NONE);

        Composite composite = new Composite(this, SWT.NONE);
        composite.setLayout(new GridLayout(1, false));

        Button btnModifierCeClient = new Button(composite, SWT.NONE);
        btnModifierCeClient.setImage(SWTResourceManager.getImage(CustomersTab.class, "/img/user_edit.png"));
        btnModifierCeClient.setText("Modifier ce client");
    }
}

WindowBuilder で UI を構築しているときに、次Labelのような未使用の s が大量に追加されることがあります。

public class CustomersTab extends Composite {
    CustomersList mCustomersList;
    CustomerBadge mCustomerBadge;
    private final Table mtable;

    public CustomersTab(final Composite parent, final int style) {
        super(parent, style);
        setLayout(new GridLayout(3, false));

        final Composite leftPanel = new Composite(this, SWT.NONE);
        leftPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        leftPanel.setLayout(new GridLayout(1, false));

        final Label lblRerchercher = new Label(leftPanel, SWT.NONE);
        lblRerchercher.setFont(SWTResourceManager.getFont("Lucida Grande", 13, SWT.BOLD | SWT.ITALIC));
        lblRerchercher.setText("Clients");
        mCustomersList = new CustomersList(leftPanel, SWT.NONE);
        mCustomersList.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1));

        final Label label = new Label(this, SWT.SEPARATOR | SWT.VERTICAL);
        label.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1));

        final Composite rightPanel = new Composite(this, SWT.NONE);
        rightPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
        rightPanel.setLayout(new GridLayout(1, false));

        mCustomerBadge = new CustomerBadge(rightPanel, SWT.NONE);
        mCustomerBadge.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);
        new Label(mCustomerBadge, SWT.NONE);

        final Label label_2 = new Label(rightPanel, SWT.NONE);
        label_2.setText("Détails");
        label_2.setFont(SWTResourceManager.getFont("Lucida Grande", 13, SWT.BOLD | SWT.ITALIC));

        mtable = new Table(rightPanel, SWT.BORDER | SWT.FULL_SELECTION);
        mtable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        mtable.setHeaderVisible(true);
        mtable.setLinesVisible(true);

        final Label label_1 = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
        label_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        new Label(this, SWT.NONE);

        final Label label_3 = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
        label_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

        final Button btnNewButton = new Button(this, SWT.NONE);
        btnNewButton.setImage(SWTResourceManager.getImage(CustomersTab.class, "/img/user_add.png"));
        btnNewButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
        btnNewButton.setText("Nouveau client");
        new Label(this, SWT.NONE);

        Composite composite = new Composite(this, SWT.NONE);
        composite.setLayout(new GridLayout(1, false));

        Button btnModifierCeClient = new Button(composite, SWT.NONE);
        btnModifierCeClient.setImage(SWTResourceManager.getImage(CustomersTab.class, "/img/user_edit.png"));
        btnModifierCeClient.setText("Modifier ce client");
    }
}

理由はわかりません。コード ビューに戻ってラベルを何度も削除する必要があり、時間を無駄にするため、これを修正する方法を知りたいと思います。

4

1 に答える 1

1

さて、Windowbuilder はレイアウトを空のプレースホルダーで埋めます。

例えば:

3 つの列があり、6 つのコントロールが作成されています。つまり、最初の 2 行がコントロールで埋められています。3 行目の最初の列 (レイアウトの次の「スペース」になります) ではなく、たとえば 5 行目の 2 列目に WindowBuilder を使用してコントロールを追加する場合、Windowbuilder は完全な 3 番目と 2 番目の列に対してこれらのダミー ラベルを作成する必要があります。 4行目と5行目の最初の列のため、これらのダミーラベルを7つ追加します。とった?

于 2012-08-06T06:53:20.867 に答える