APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Using the 'Custom' panel to centralize code editing

Return to the EJS Modeling forum
Login to post to this thread

Using the 'Custom' panel to centralize code editing
Cleon Teunissen
27 Posts

To describe my question, let me explain how I work. View elements such as buttons, checkboxes and numberfields have among their properties that you can define an action. I write that action handling code in a method in the Custom panel. In the view element properties box, in the field 'Action' I only write the call to that method. That way, when I want to edit the code for that action I don't have to dig down into the view element tree, all the code is directly accessible in the Custom panel.

I now have two simulations that use the 'evolution event' capability of EJS. Can I do the same thing with the code in the 'Events for ODE evolution' box?

The reason I ask is that in the upper section, with the code for the zero condition, the code returns a value.

Of course, for one thing the method in the Custom panel must then not be declared as a 'void' method; void methods are methods that do not return a value. Java being a type-aware language I assume that when the returned value is type double you declare 'double' instead of 'void'.

Yeah, I could just try that and see if it works, but I decided to ask anyway.


Current Replies - View all
Re: Using the 'Custom' pa...   (Francisco Esquembre - )
Re: Using the 'Custom' pa...   (Cleon Teunissen - )
OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book