看到网上有人提出这样的问题,他的代码是有些问题的。
不在乎问题有多深,在乎解决方法和点滴的积累。
完整的小例子,大家可以跑跑,点点。
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class DynamSample{
Display display;
Shell shell;
Composite c;
Composite c1;
Composite c2;
public DynamSample(){
display = new Display();
shell = new Shell(display);
shell.setText("SWT Sample");
shell.setLayout( new FillLayout(SWT.VERTICAL));