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.

Access view objects from Custom java code

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

Custom Page : code to access object properties
7 Posts

I am trying to write custom code that can interact with view objects.

For example:

// =====================
public double getmode () {
  double getmode;

getmode = 111.23;

getmode = _view.plate.getX();    

//  The view contains a 3d drawing panel with a cylinder named "plate"

  return getmode;

// =====================

This gives a run time error like this:

Exception in thread "main" java.lang.NullPointerException
at users.__psb.simple_plate_pkg.simple_plate.getmode(simple_plate.java:458)
at users.__psb.simple_plate_pkg.simple_plate.(simple_plate.java:251)
at users.__psb.simple_plate_pkg.simple_plate.(simple_plate.java:137)
at users.__psb.simple_plate_pkg.simple_plate.main(simple_plate.java:126)

-- Praveen

Attached File: simple_plate.zip

Current Replies - View all
Re: Custom Page : code to...   (Francisco Esquembre - )
OSP Projects:
Open Source Physics - EJS Modeling
Physlet Physics
Physlet Quantum Physics
STP Book