gpt4 book ai didi

java.lang.NoClassDefFoundError : org/eclipse/draw2d/LightweightSystem

转载 作者:行者123 更新时间:2023-12-01 04:54:12 26 4
gpt4 key购买 nike

我正在使用 Eclipse 图形编辑框架 ( GEF ) 构建 Eclipse 插件项目。可以用我在互联网上找到的示例代码编写一个类进行测试,代码如下:

public class Test {
public static void main(String args[]){
Shell shell = new Shell();
shell.open();
Display display = shell.getDisplay();
LightweightSystem lws = new LightweightSystem(shell);
IFigure panel = new Figure();
lws.setContents(panel);
RectangleFigure node1 = new RectangleFigure();
RectangleFigure node2 = new RectangleFigure();
node1.setBackgroundColor(ColorConstants.red);
node1.setBounds(new Rectangle(30, 30, 64, 36));
node2.setBackgroundColor(ColorConstants.blue);
node2.setBounds(new Rectangle(300, 300, 64, 36));
PolylineConnection conn = new PolylineConnection();
conn.setSourceAnchor(new ChopboxAnchor(node1));
conn.setTargetAnchor(new ChopboxAnchor(node2));
conn.setTargetDecoration(new PolygonDecoration());
Label label = new Label("Midpoint");
label.setOpaque(true);
label.setBackgroundColor(ColorConstants.buttonLightest);
label.setBorder(new LineBorder());
conn.add(label, new MidpointLocator(conn, 0));
panel.add(node1);
panel.add(node2);
panel.add(conn);
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ())
display.sleep ();
}
}//main
}

它有效。

但是 - 当我尝试在 EditorPart (org.eclipse.ui.IEditorPart) 实例类中构建图形时,它变得很糟糕并给出以下错误代码:

**org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError:** org/eclipse/draw2d/LightweightSystem

这很奇怪,因为我只在编辑器的 createPartControl 方法中写了 3 行:

Shell shell = parent.getShell();
Display display = shell.getDisplay();
LightweightSystem lws = new LightweightSystem(shell);

有没有人帮忙?

最佳答案

您的依赖项设置正确吗?您需要为 LightweightSystem 添加org.eclipse.draw2d

关于java.lang.NoClassDefFoundError : org/eclipse/draw2d/LightweightSystem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14434906/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com