I have a program with two drop down lists: the Make (Ford, Chrysler, etc) and the Model of a car (Bronco, Concorde, etc)
Here is the error:
When you choose an item from the Make list, it clears the Model list and then adds the appropriate models. I use the Model.clear() method to clear the Model list. This works 90% of the time, but with some Makes selected, I get an error.
I have added a "Clearing" and "Cleared" print line on either side of the .clear method to catch the bug. When I get an error, it will print "Clearing", print the error, then stop without printing "Cleared".
Here is the error:
ClearingMar 15, 2011 2:54:03 PM controlP5.ControlBroadcaster printMethodErrorSEVERE: An error occured while forwarding a Controller value to a method in your program. Please check your code for any possible errors that might occur in this method. e.g. check for casting errors, possible nullpointers, array overflows ... .method: controlEventexception: java.lang.reflect.InvocationTargetException
Here's the relevant code:
- void controlEvent(ControlEvent theEvent) {
- int minValue = int(Float.MAX_VALUE);
- if (theEvent.isGroup()) {
- // check if the Event was triggered from a ControlGroup
- if(theEvent.group().name() == "Make"){
- println("Clearing");
- Model.clear();
- println("Clear");
- for(int i=0;i<Models.length;i++){
- if(MakeID[i] == int(Make.value())){
- Model.addItem(Models[i],i);
- minValue = min(minValue,i);
- }
- Model.setValue(minValue);
- Model.scroll(0);
- }
- }
Is there something I'm missing with using the .clear() function? Are there any other options to remove the values of the drop down list and switch them out with other values?
Thank you!
1