各位大虾在很多网络上搜索的资料都是以插件的形式做,我也是按照网络上的引入,还是在插件项目中创建了个main函数测试运行了下XWT是可以但是上面没有说明使用CSS的,我在官网上copy了一段代码运行了报错,麻烦各位看下
官网上的代码如下
                Display display = new Display();
Shell shell = new Shell();
shell.setLayout(new GridLayout());

RegistryFactory.getRegistry();

Label label = new Label(shell, SWT.LEAD);
label.setText("Hello world!");
label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
CSSEngine engine = new CSSSWTEngineImpl(display);

engine.parseStyleSheet(new StringReader("Label { color: blue }"));

engine.setErrorHandler(new CSSErrorHandler() {
  public void error(Exception e) {
    e.printStackTrace();
  }
});
// applying styles to the child nodes means that the engine
// should recurse downwards, in this example, the engine
// should style the children of the Shell
engine.applyStyles(shell, /* applyStylesToChildNodes */ true);
 
shell.setSize(400, 300);
shell.open();
 
while (!shell.isDisposed()) {
  if (!display.readAndDispatch()) {
    display.sleep();
  }
}
display.dispose();
报出的错误如下:Exception in thread "main" java.lang.NullPointerException
at org.eclipse.e4.ui.css.core.impl.engine.CSSEngineImpl.<init>(CSSEngineImpl.java:45)
at org.eclipse.e4.ui.css.swt.engine.AbstractCSSSWTEngineImpl.<init>(AbstractCSSSWTEngineImpl.java:39)
at org.eclipse.e4.ui.css.swt.engine.AbstractCSSSWTEngineImpl.<init>(AbstractCSSSWTEngineImpl.java:36)
at org.eclipse.e4.ui.css.swt.engine.CSSSWTEngineImpl.<init>(CSSSWTEngineImpl.java:72)
at com.xwt.css.test.helloworld.Test.main(Test.java:30)