Java 使用leap motion controller单击按钮后Swing应用程序崩溃
我试着编写一个小的swing应用程序,其中我用leap motion控制器移动鼠标(这是可行的),然后通过屏幕点击手势点击按钮。它所做的是显示按钮被单击,但随后应用程序在控制台上的输出崩溃:Java 使用leap motion controller单击按钮后Swing应用程序崩溃,java,swing,leap-motion,Java,Swing,Leap Motion,我试着编写一个小的swing应用程序,其中我用leap motion控制器移动鼠标(这是可行的),然后通过屏幕点击手势点击按钮。它所做的是显示按钮被单击,但随后应用程序在控制台上的输出崩溃: A fatal error has been detected by the Java Runtime Environment: EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000678f09fc, pid=3796, tid=2124
A fatal error has been detected by the Java Runtime Environment:
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000678f09fc, pid=3796, tid=2124
JRE version: 7.0_21-b11
Java VM: Java HotSpot(TM) 64-Bit Server VM (23.21-b01 mixed mode windows-amd64 compressed oops)
Problematic frame:
V [jvm.dll+0x1b09fc]
Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
If you would like to submit a bug report, please visit:
http://bugreport.sun.com/bugreport/crash.jsp
这是我的LeapListener类中鼠标单击的代码:
GestureList gList = frame.gestures();
for (int i = 0; i < gList.count(); i++){
Gesture g = gList.get(i);
if (g.type().equals(Gesture.Type.TYPE_SCREEN_TAP)){
@SuppressWarnings("unused")
ScreenTapGesture tap = new ScreenTapGesture(g);
System.out.println("geklickt");
this.getButton().doClick();
}
}
怎么了?
编辑:
我使用了mKorbel的提示(谢谢)并尝试了System.exit(0);而不是dispose();但这也不起作用。在dispose()的情况下会发生什么;应该链接,参考顶级容器的局部变量,例如myFrame.dispose(),奇怪的是,当我这样做时,它说frame没有dispose方法。顺便说一句,我使用JFrame作为gui的父类。为了更好地帮助我,请尽快发布一个简短、可运行、可编译的JFrame和JButton引起的上午问题,
button = new JButton("Close");
button.setSize(100, 40);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (e.equals("Close")){
dispose();
}
}
});