Hi,
I did a form with G4P GUI. I added only one line at the event of a text field.
It looks that the event can’t handle the typing of one character at the field and crashes.
I am getting this error while executing the code below.
=======================================================
G4P V4.3.6 created by Peter Lager
=======================================================
textfield1 - GTextField >> GEvent.GETS_FOCUS @ 9017
textfield1 - GTextField >> GEvent.CHANGED @ 10347
java.lang.NullPointerException
at g4p_controls.GTextField.keyEvent(Unknown Source)
at g4p_controls.GWindowImpl.sendKeyEvent(Unknown Source)
at g4p_controls.GWindowImpl.keyEvent(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1436)
at processing.core.PApplet.handleMethods(PApplet.java:1638)
at processing.core.PApplet.handleKeyEvent(PApplet.java:3021)
at processing.core.PApplet.dequeueEvents(PApplet.java:2655)
at processing.core.PApplet.handleDraw(PApplet.java:2493)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:313)
NullPointerException
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help → Troubleshooting.
The line in conflict is:
textfield1.setText("any text"); // <---------- THIS LINE CONFLICTS
Here is the code and the conflicting line is at line 30
import g4p_controls.*;
void setup() {
size(640, 360);
createGUI();
}
void draw() {
}
/* =========================================================
* ==== WARNING ===
* =========================================================
* The code in this tab has been generated from the GUI form
* designer and care should be taken when editing this file.
* Only add/edit code inside the event handlers i.e. only
* use lines between the matching comment tags. e.g.
void myBtnEvents(GButton button) { //_CODE_:button1:12356:
// It is safe to enter your event code here
} //_CODE_:button1:12356:
* Do not rename this tab!
* =========================================================
*/
public void textfield1_change1(GTextField source, GEvent event) { //_CODE_:textfield1:346564:
println("textfield1 - GTextField >> GEvent." + event + " @ " + millis());
textfield1.setText("any text"); // <---------- THIS LINE CONFLICTS
} //_CODE_:textfield1:346564:
// Create all the GUI controls.
// autogenerated do not edit
public void createGUI(){
G4P.messagesEnabled(false);
G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
G4P.setMouseOverEnabled(false);
surface.setTitle("Sketch Window");
textfield1 = new GTextField(this, 20, 10, 120, 30, G4P.SCROLLBARS_NONE);
textfield1.setOpaque(true);
textfield1.addEventHandler(this, "textfield1_change1");
}
// Variable declarations
// autogenerated do not edit
GTextField textfield1;