Null pointer exception with FengGUI tabbing

I started to play around with FengGUI and ran into a null pointer exception. First off let me say that I turned tabbing back on by adding it to the FengJMEInputHandler:


case Keyboard.KEY_TAB:
      keyClass = Key.TAB;
      break;



I then made a frame with a text editor field and two buttons since I wanted to play with tabbing. (Side question: anyone know how to implement backwards tabbing with shit-tab?). I added a buttonPressedListener to the first button that removes the first frame. The second button exits the application.

What's strange is this works whenever I use the mouse to press the "close" button to remove the frame. It will also work if, after you've clicked on the text field, you move the mouse, than tab to the "close" button and hit enter. However, if you do not move the mouse after clicking on the text field, tab to the "close" button and press enter, as soon as you move the mouse again you get the following:


java.lang.NullPointerException
   at org.fenggui.TextEditor$3.mouseExited(TextEditor.java:152)
   at org.fenggui.ObservableWidget.mouseExited(ObservableWidget.java:222)
   at org.fenggui.Display.fireMouseMovedEvent(Display.java:560)
   at FengJMEInputHandler$MouseListener.onMove(FengJMEInputHandler.java:201)
   at com.jme.input.lwjgl.LWJGLMouseInput.update(LWJGLMouseInput.java:200)
   at com.jme.input.InputSystem.update(InputSystem.java:67)
   at com.jme.app.BaseGame.start(BaseGame.java:63)
   at FengJME.main(FengJME.java:287)



As soon as you move the mouse the exception occurs.

Here is the relevant FengGUI items I've done:

      
                frame1 = new Window();
      disp.addWidget(frame1);
      frame1.setTitle("frame1");
      frame1.setXY(200, 200);
      frame1.setSize(300, 300);
      frame1.getContentContainer().setLayoutManager(new FormLayout());
      FormData fd = new FormData();
      
      TextEditor text = new TextEditor();
      text.setMultiline(false);
      text.setShrinkable(false);
      text.setSize(100, text.getMinHeight());
      frame1.getContentContainer().addWidget(text);
      fd.left = new FormAttachment(0,0);
      fd.top = new FormAttachment(100,0);
      text.setLayoutData(fd);
      
      Button button1 = new Button("close");
      fd = new FormData();
      fd.left = new FormAttachment(0,0);
      fd.top = new FormAttachment(text,0);
      button1.setLayoutData(fd);
      frame1.getContentContainer().addWidget(button1);
      button1.addButtonPressedListener(new IButtonPressedListener() {
         public void buttonPressed(ButtonPressedEvent e) {
            disp.removeWidget(frame1);
            disp.layout();
         }
      });
      
      Button button2 = new Button("exit");
      fd = new FormData();
      fd.left = new FormAttachment(0,0);
      fd.top = new FormAttachment(button1,0);
      button2.setLayoutData(fd);
      frame1.getContentContainer().addWidget(button2);
      button2.addButtonPressedListener(new IButtonPressedListener() {
         public void buttonPressed(ButtonPressedEvent e) {
            finish();
         }
      });
      
      disp.layout();

Hi!



Yeah, tabbing is still a bit premature in FengGUI yet. But we are working on it :slight_smile:



As for the NullPointerException; this should not happen of course and I already fixed it so that your code will not crash anymore with the newest FengGUI (which I will upload tomorrow I guess). But I can send you the most current jar by email if you like (my address is johannes.schaback "at" gmail.com)



Johannes

Many thanks. Sending you e-mail presently.