swift 即使导入库并安装所有组件后,Eclipse中的WindowBuilder也无法工作

p3rjfoxz  于 2022-10-31  发布在  Swift
关注(0)|答案(2)|浏览(153)

在我的学习中,我只得到了关于Swing和Java GUI管理的非常简短的指导,所以我决定自己动手,并试图弄清楚如何使用Java构建一个好看的GUI。
在这样做的时候,我遇到了WindowBuilder,并决定将其添加到我已经构建的项目中,目前我通过控制台(一个使用pIRCbot库的Twitch Bot)的用户输入来工作。然而,即使在将WindowBuilder导入到我的项目中,扩展Composite并执行官方教程第一部分中所示的操作后,我仍然收到一个错误消息:
未知的GUI工具包分析程序分析了编译单元,但不能识别任何GUI工具包,因此WindowBuilder不能显示任何GUI来编辑。这可能是由下列原因之一引起的:
该类不是可编辑的UI类,并且不包含UI组件。WindowBuilder无法识别该类中使用的GUI工具包或库。WindowBuilder无法识别受支持的GUI工具包中的GUI类型/模式。类路径存在问题。例如,编译单元使用SWT类,但SWT/JFace库未包含在类路径中。
这是堆栈跟踪:

org.eclipse.wb.internal.core.utils.exception.DesignerException: 103 (Unknown GUI toolkit). twitchChatBot.MyBotMain
at org.eclipse.wb.internal.core.parser.JavaInfoParser.prepareParseContext(JavaInfoParser.java:1195)
at org.eclipse.wb.internal.core.parser.JavaInfoParser.parse(JavaInfoParser.java:242)
at org.eclipse.wb.internal.core.parser.JavaInfoParser.access$9(JavaInfoParser.java:238)
at org.eclipse.wb.internal.core.parser.JavaInfoParser$1.runObject(JavaInfoParser.java:153)
at org.eclipse.wb.internal.core.parser.JavaInfoParser$1.runObject(JavaInfoParser.java:1)
at org.eclipse.wb.internal.core.utils.execution.ExecutionUtils.runDesignTime(ExecutionUtils.java:159)
at org.eclipse.wb.internal.core.parser.JavaInfoParser.parse(JavaInfoParser.java:151)
at org.eclipse.wb.internal.core.editor.DesignPage.internal_refreshGEF(DesignPage.java:534)
at org.eclipse.wb.internal.core.editor.DesignPage.access$9(DesignPage.java:522)
at org.eclipse.wb.internal.core.editor.DesignPage$8$1.run(DesignPage.java:449)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:236)
at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:146)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:5786)
at org.eclipse.wb.internal.core.editor.DesignPage$8.run(DesignPage.java:446)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:436)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:352)
at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:469)
at org.eclipse.wb.internal.core.editor.DesignPage.internal_refreshGEF_withProgress(DesignPage.java:465)
at org.eclipse.wb.internal.core.editor.DesignPage.internal_refreshGEF(DesignPage.java:415)
at org.eclipse.wb.internal.core.editor.UndoManager.refreshDesignerEditor(UndoManager.java:381)
at org.eclipse.wb.internal.core.editor.UndoManager.activate(UndoManager.java:90)
at org.eclipse.wb.internal.core.editor.DesignPage.handleActiveState_True(DesignPage.java:263)
at org.eclipse.wb.internal.core.editor.DesignPage.handleActiveState(DesignPage.java:241)
at org.eclipse.wb.internal.core.editor.multi.DefaultMultiMode.showPage(DefaultMultiMode.java:125)
at org.eclipse.wb.internal.core.editor.multi.DefaultMultiMode$1.widgetSelected(DefaultMultiMode.java:63)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5676)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1423)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1449)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1432)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1221)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3193)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1876)
at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:330)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5676)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1423)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4935)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4429)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:660)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:559)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:154)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)

下面是我试图在WindowBuilder中打开的类的代码:

package twitchChatBot;
import java.io.IOException;
import org.eclipse.swt.widgets.Composite;
import org.jibble.pircbot.*;

public class MyBotMain extends Composite {

    private String channel;

    public MyBotMain(Composite parent, int style) {
        super(parent, style);
        }

    public static void main(String[] args) {
        decideChannel();
        }

    public static void decideChannel() {
        connectToChannel("");
    }

    public static void connectToChannel(String channel) {
        MyBot bot = new MyBot(channel);
        try {
            bot.connect("irc.twitch.tv.", 6667, "oauth:***");
        }
        catch(NickAlreadyInUseException e) {
            System.out.println("Username already in use!");
        }
        catch(IrcException e) {
            System.out.println("General error!");
        }
        catch(IOException e) {
            System.out.println("IO error!");
        }
   }
    @SuppressWarnings("unused")
    private void setChannel(String channel) {this.channel = channel;}
    @SuppressWarnings("unused")
    private String getChannel() {return this.channel;}

    @Override
    protected void checkSubclass() {

    }

}

我尝试了我能找到的大多数修复方法,但似乎没有一个能帮我解决问题。有人知道发生了什么吗?
提前感谢!:)
编辑1:按要求添加源代码:)

wlp8pajw

wlp8pajw1#

您扩展了需要WindowBuilder的SWT功能的SWT组合。可能您只安装了Swing支持功能。
最好的建议是使用帮助菜单从Eclipse Marketplace安装WindowBuilder。然后接受所有建议的选择。不要安装XWT支持。
重新启动后,GUI Toolkit应能被设计人员识别。

h7appiyu

h7appiyu2#

很晚才做出回应,但仍在为其他正在搜索这个解决方案的人发帖,正如我所看到的,许多其他人已经在其他平台上搜索了答案,包括这里。
我遇到了这个问题,在“设计”选项卡下它会说“已知的GUI工具包“,在”问题“选项卡下也有几个错误,主要是读“jframe无法解析为一种类型“
我可以通过删除module-info.java来解决这个问题。我忘了我在哪里读到它没有包含在要使用的产品中,但它建议输入其他内容。当这不起作用时,我简单地删除了它,因为我拥有的版本更新得多。
瞬间解决。

相关问题