【发布时间】:2017-06-16 11:23:23
【问题描述】:
我有一个组合,我在启动视图时创建了五个文本框。有一个点击按钮,我想用组合框替换第四个文本框。问题是我无法从头开始重新加载页面,因为我想显示文本框的当前值。
这是一个sn-p。
public class DisposeDemo {
private static void addControls(Shell shell) {
shell.setLayout(new GridLayout());
Text textOne=new Text(shell, SWT.BORDER);
Text textTwo=new Text(shell, SWT.BORDER);
Text textThree=new Text(shell, SWT.BORDER);
Text textFour=new Text(shell, SWT.BORDER);
Text textFive=new Text(shell, SWT.BORDER);
Button button = new Button(shell, SWT.PUSH);
button.setText("Replace text with Combo");
button.addSelectionListener(new SelectionAdapter() {
@Override public void widgetSelected(SelectionEvent event) {
//What code should go here to Replace the textFour with a combo
}
});
shell.pack();
}
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
addControls(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
【问题讨论】: