I'm trying to write a big program that loads a Periodic Table from a text file and then ask questions about it. I'm a Chemistry teacher trying to write a program that will help my students get really fast feedback on their homework (and cut down on the time I spend grading. :)
I have a basic version of the program that works. The code is spread across 7 tabs so I'll call it the "7 tabs version". I recently made a small change to it (I'm not sure what it was, it was only a few lines) and started getting a runtime error. To try and debug it I copied all of the files into a new sketch but with all the tabs on 1 page. I'll call this the "1 page version".
Both versions of the program contain identical code, but the "7 tabs version" has it in 7 tabs, and the "1 page version" has it all on 1 page.
I'll summarize what I've found with bullet points:
The "7 tabs version" gives me a runtime error when it's the only sketch I have open.
The "1 page version" always works exactly like it should.
If I have the "7 tabs version" open along with the "1 page version", then the "7 tabs version" will also work!
If I close "1 page version" and then run the "7 tabs version", the "7 tabs version" will give me the runtime error again
Does anybody have any idea what's going on? Or even better, what I can do to fix this? If I have to keep all the code on one page I will, but it felt much cleaner in tabs.
The runtime error message I get is copied below. The code is really long so I'll avoid posting it here unless people think it will help.
################ EXCEPTION IN EVENT HANDLER ################
An error occured during execution of the eventhandler:
CLASS: Elements_File_Reader_GUI_Interface_6 METHOD: nameEntryButton_click1
Caused by java.lang.ArrayIndexOutOfBoundsException: 0
Elements_File_Reader_GUI_Interface_6.askQuestionB(Elements_File_Reader_GUI_Interface_6.java:303)
Elements_File_Reader_GUI_Interface_6.nameEntryButton_click1(Elements_File_Reader_GUI_Interface_6.java:456)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
g4p_controls.GAbstractControl.fireEvent(Unknown Source)
g4p_controls.GButton.mouseEvent(Unknown Source)
g4p_controls.GWindowInfo.mouseEvent(Unknown Source)
sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1084)
processing.core.PApplet.handleMethods(PApplet.java:1279)
processing.core.PApplet.handleMouseEvent(PApplet.java:2560)
processing.core.PApplet.dequeueEvents(PApplet.java:2463)
processing.core.PApplet.handleDraw(PApplet.java:2153)
processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:193)
processing.core.PApplet.run(PApplet.java:2020)
java.lang.Thread.run(Thread.java:662)
##############################################################
I just updated to the latest versions of G4P and the G4P Tool, but now setFont() isn't working to control the font used in my GLabels. Is this because of the new StyledString that was implemented?
Back when the G4P GUI Builder had "import guicomponents.*", after I created a label I could go:
label1.setFont("Arial",24);
and the font would change.
I'm working on writing a program to help me teach Chemistry and I'm looking for a way to make some text superscript (and subscript), so that I can write Atomic Number, Atomic Mass, Charge, etc. next to Element Symbols. I've been looking around the interwebs for awhile but haven't found any way to make it work.
I am using the G4P library to put my text in the window (using GTextField). but I don't think my question is specific to the G4P library. (Please tell me if I'm wrong).