如何在 Eclipse 中调试 JComboBox 的 actionEvent 的处理并避免锁定窗口系统?

发布于 2024-11-07 19:30:44 字数 2217 浏览 0 评论 0原文

我编写了一个带有 Swing GUI 的 Eclipse 插件。为了调试该插件,我生成了一个辅助 Eclipse 工作区。然后,我在从 JComboBox 选择菜单项时由 actionPerformed 方法调用的方法上设置断点。

当我从 JComboBox 中选择一个项目时,我的 GUI 冻结并显示整个 JComboBox 的菜单。代表 Eclipse 调试工作区的 KDE 图标会像命中断点时一样闪烁。不幸的是,此时我的 KDE 会话已经结束了。我可以移动鼠标,但选择任何窗口或图标都没有效果(包括闪烁的 Eclipse 调试图标)。我无法在 KDE 中执行任何操作,因此我通过 进入常规终端窗口并终止 Eclipse 进程。这使我能够再次在 KDE 中做事。

我该如何避免 KDE 4.5.5 中的这种锁定并调试我的代码?以下是一些相关的 Java 和 Eclipse 属性:

eclipse.buildId=M20100909-0800
eclipse.commands=-os
linux
-ws
gtk
-arch
x86
-showsplash
/am/embassy/vol/x6/eclipse/eclipse-jee-helios-SR1//plugins/org.eclipse.platform_3.6.1.v201009090800/splash.bmp
-launcher
/am/embassy/vol/x6/eclipse/eclipse-jee-helios-SR1/eclipse
-name
Eclipse
--launcher.library
/am/embassy/vol/x6/eclipse/eclipse-jee-helios-SR1//plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.1.1.R36x_v20100810/eclipse_1309.so
-startup
/am/embassy/vol/x6/eclipse/eclipse-jee-helios-SR1//plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
-product
org.eclipse.epp.package.jee.product
-clean
-debug
-vm
/usr/pkg/java/sun-6/bin/../lib/i386/client/libjvm.so
java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment
java.awt.printerjob=sun.print.PSPrinterJob
java.class.path=/am/embassy/vol/x6/eclipse/eclipse-jee-helios-SR1//plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
java.class.version=50.0
java.endorsed.dirs=/usr/pkg/java/sun-6/lib/endorsed
java.ext.dirs=/usr/pkg/java/sun-6/lib/ext:/usr/java/packages/lib/ext
java.home=/usr/pkg/java/sun-6
java.library.path=/usr/pkg/java/sun-6/lib/i386/client:/usr/pkg/java/sun-6/lib/i386:/usr/pkg/lib:::/usr/java/packages/lib/i386:/lib:/usr/lib
java.runtime.name=Java(TM) SE Runtime Environment
java.runtime.version=1.6.0_22-b04
java.specification.name=Java Platform API Specification
java.specification.vendor=Sun Microsystems Inc.
java.specification.version=1.6
java.vendor=Sun Microsystems Inc.
java.version=1.6.0_22
java.vm.info=mixed mode, sharing
java.vm.name=Java HotSpot(TM) Client VM
java.vm.specification.name=Java Virtual Machine Specification
java.vm.specification.vendor=Sun Microsystems Inc.
java.vm.specification.version=1.0
java.vm.vendor=Sun Microsystems Inc.
java.vm.version=17.1-b03

I have written an Eclipse plugin that has a Swing GUI. To debug the plugin, I spawn a secondary Eclipse workspace. I then set a breakpoint on a method that gets called by an actionPerformed method when a menu item is chosen from a JComboBox.

When I choose an item from the JComboBox, my GUI freezes with the entire JComboBox's menu shown. The KDE icon representing the Eclipse debugging workspace flashes as it usually does when a breakpoint is hit. Unfortunately, at this point, my KDE session is hosed. I can move my mouse about, but selecting any window or icon has no effect (including the flashing Eclipse debugging icon). I can't do anything in KDE, so I go to a regular terminal window via and kill off the eclipse process. This enables me to do things in KDE again.

What can I do to avoid this lockup in KDE 4.5.5 and debug my code? Here are some of the relevant Java and Eclipse properties:

eclipse.buildId=M20100909-0800
eclipse.commands=-os
linux
-ws
gtk
-arch
x86
-showsplash
/am/embassy/vol/x6/eclipse/eclipse-jee-helios-SR1//plugins/org.eclipse.platform_3.6.1.v201009090800/splash.bmp
-launcher
/am/embassy/vol/x6/eclipse/eclipse-jee-helios-SR1/eclipse
-name
Eclipse
--launcher.library
/am/embassy/vol/x6/eclipse/eclipse-jee-helios-SR1//plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.1.1.R36x_v20100810/eclipse_1309.so
-startup
/am/embassy/vol/x6/eclipse/eclipse-jee-helios-SR1//plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
-product
org.eclipse.epp.package.jee.product
-clean
-debug
-vm
/usr/pkg/java/sun-6/bin/../lib/i386/client/libjvm.so
java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment
java.awt.printerjob=sun.print.PSPrinterJob
java.class.path=/am/embassy/vol/x6/eclipse/eclipse-jee-helios-SR1//plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
java.class.version=50.0
java.endorsed.dirs=/usr/pkg/java/sun-6/lib/endorsed
java.ext.dirs=/usr/pkg/java/sun-6/lib/ext:/usr/java/packages/lib/ext
java.home=/usr/pkg/java/sun-6
java.library.path=/usr/pkg/java/sun-6/lib/i386/client:/usr/pkg/java/sun-6/lib/i386:/usr/pkg/lib:::/usr/java/packages/lib/i386:/lib:/usr/lib
java.runtime.name=Java(TM) SE Runtime Environment
java.runtime.version=1.6.0_22-b04
java.specification.name=Java Platform API Specification
java.specification.vendor=Sun Microsystems Inc.
java.specification.version=1.6
java.vendor=Sun Microsystems Inc.
java.version=1.6.0_22
java.vm.info=mixed mode, sharing
java.vm.name=Java HotSpot(TM) Client VM
java.vm.specification.name=Java Virtual Machine Specification
java.vm.specification.vendor=Sun Microsystems Inc.
java.vm.specification.version=1.0
java.vm.vendor=Sun Microsystems Inc.
java.vm.version=17.1-b03

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

友谊不毕业 2024-11-14 19:30:44

如下所述: https://bugs.java.com/bugdatabase/view_bug?bug_id= 6714678,解决方法是通过添加以下内容来禁用 X11 平台上的抓取: -Dsun.awt.disablegrab=true 到 VM 参数。

As described here: https://bugs.java.com/bugdatabase/view_bug?bug_id=6714678, the workaround is disabling acquiring grabs on X11 platform by adding: -Dsun.awt.disablegrab=true to VM arguments.

予囚 2024-11-14 19:30:44

我忽略了用 SwingUtilities.invokeLater() 包装 ActionEvent 的处理。一旦我这样做了,我的问题就解决了。

I had neglected to wrap the processing of the ActionEvent with SwingUtilities.invokeLater(). Once I did so, my problem was solved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文