我正在尝试将新的合成添加到我的对话框中。我正在创建一个简单的按钮,我想把它放在对话框中。我首先创建了一个方法来创建 Button 区域。此方法正在调用创建简单按钮的方法。新按钮未显示在对话框中。
这是完整的代码
public class AplotBaseDialog extends TitleAreaDialog {
private TCSession session= null;
public AplotBaseDialog(Shell parentShell, TCSession theSession) {
super(parentShell);
session = theSession;
}
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
composite.setLayout(layout);
// The text fields will grow with the size of the dialog
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalAlignment = GridData.BEGINNING;
Label label1 = new Label(composite, SWT.NONE);
label1.setText("First Name");
label1.setLayoutData(gridData);
gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalAlignment = GridData.CENTER;
Label label2 = new Label(composite, SWT.NONE);
label2.setText("Last Name");
label2.setLayoutData(gridData);
gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalAlignment = GridData.END;
Button button1 = new Button(composite, SWT.PUSH);
button1.setText("Button 5");
button1.setLayoutData(gridData);
return composite;
}
protected void createButtonArea(Composite parent){
GridData gridData = new GridData();
gridData.horizontalAlignment = SWT.CENTER;
parent.setLayoutData(gridData);
createOkButton(parent);
}
protected Button createOkButton(Composite parent) {
// increment the number of columns in the button bar
((GridLayout) parent.getLayout()).numColumns++;
Button button = new Button(parent, SWT.PUSH);
button.setText("Test Button");
setButtonLayoutData(button);
return button;
}
}
为什么测试按钮没有显示在对话框中?
在 SWT/Jface 中是否有可能发生这样的事情?
有人可以向我展示执行对话框之类的方法的布局吗?