Reputation: 12384
I'm using Google's WindowBuilder to create UIs in Eclipse for desktop Java/SWT applications. I'm using Mac OS X.
I've got this simple class (imports removed for clarity):
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");
}
}
When I'm building my UI with WindowBuilder, it happens sometimes that it adds a lot of unused Label
s like this:
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");
}
}
I have no idea why, and I'd like to know how to fix this because I have to switch back to the code view and remove the labels quite a lot, which makes me waste time.
Upvotes: 0
Views: 809
Reputation: 9535
Well, Windowbuilder fills the layout with empty placeholders.
For example:
You have 3 columns and have created 6 controls, that means the first two rows are filled with your controls. If you now add a conrol with WindowBuilder not in the 3rd row first column (which would be next "space" in your layout), but for example in the 5th row 2nd column, Windowbuilder has to create these dummy labels for the complete 3rd and 4th row and for the first column of the fith row, so it will add 7 of these dummy-labels. Got it?
Upvotes: 1