在图书馆看了一本关于eclipse插件开发的老书,就敲了起来
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.graphics.Color;
public class HelloWorld {
public static void main(String[] args) {
// TODO 自动生成的方法存根
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("hello world");
shell.setBounds(100, 100, 200, 50);
shell.setLayout(new FillLayout());
org.eclipse.swt.widgets.Label label = new Label(shell, SWT.CENTER);
label.setText("helloWorld");
Color red = new Color(display, 255, 0, 0);
label.setForeground(red);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
red.dispose();
display.dispose();
}
}