我开始玩弄 Leap Motion Controller 并在 Swing 中制作了一个小的 GUI。这意味着它只是一个带有标签的框架,它应该显示 Leap Motion 看到的文本。不幸的是,我的程序在两秒钟后就崩溃了。我没有例外或类似的东西。这是我的代码:
public class GUI extends JFrame{
private static final long serialVersionUID = 6411499808530678723L;
public JLabel label;
public GUI(){
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(300, 200);
this.label = new JLabel("Waiting for Gestures");
this.add(label);
setVisible(true);
}
public class LeapListener extends Listener{
JLabel label;
LeapListener(JLabel label){
this.label = label;
}
@Override
public void onInit(Controller controller){
}
@Override
public void onExit(Controller controller){
}
@Override
public void onConnect(Controller controller){
System.out.println("bin da");
controller.enableGesture(Gesture.Type.TYPE_CIRCLE);
controller.enableGesture(Gesture.Type.TYPE_KEY_TAP);
controller.enableGesture(Gesture.Type.TYPE_SCREEN_TAP);
controller.enableGesture(Gesture.Type.TYPE_SWIPE);
}
@Override
public void onDisconnect(Controller controller){
}
@Override
public void onFrame(Controller controller){
Frame frame = controller.frame();
GestureList glist = frame.gestures();
for (int i = 0; i < glist.count(); i++){
Gesture g = glist.get(i);
switch (g.type()){
case TYPE_CIRCLE:
CircleGesture circle = new CircleGesture(g);
this.label.setText("Mach mal nen Kreis!");
case TYPE_KEY_TAP:
KeyTapGesture key = new KeyTapGesture(g);
this.label.setText("Schreiben?");
case TYPE_SCREEN_TAP:
ScreenTapGesture screen = new ScreenTapGesture(g);
this.label.setText("Klicken?");
case TYPE_SWIPE:
SwipeGesture swipe = new SwipeGesture(g);
this.label.setText("Da wurde gewischt!");
default:
System.out.println("nothing!");
break;
}
}
}
}
public static void main(String[] args) {
GUI gui = new GUI();
LeapListener listener;
listener = gui.new LeapListener(gui.label);
Controller controller = new Controller();
controller.addListener(listener);
}
}
我不知道我做错了什么。Windows-Error-Message 表示 Java Platform SE 二进制文件已关闭 (javaw.exe)。Errormodule: Leap.dll 是我犯的错误还是我的整个设置都搞砸了?