How does one access the move position (x y) shown in the yellow box of the drawing panel? I wanted to click on the screen and use the mouse position for a trace or a new drawable circle or rectangle. This seems way too easy but I haven't yet found an example that uses this. Any help will be appreciated
my drawing panel is named drawingPanel for this test. My code in the evolution panel (of model) is:
int px = _view.drawingPanel.getMouseIntX(); int py = _view.drawingPanel.getMouseIntY(); _println("x= " +px +"y= "+py);
It seems to compile okay but I get the message (in output area)
Exception in thread "Thread-2" java.lang.NullPointerException at org.opensourcephysics.display.InteractivePanel.getMouseIntX(Unknown Source) at ch4.tryimage_pkg.tryimage._evolution1(tryimage.java:235) at ch4.tryimage_pkg.tryimage._stepModel(tryimage.java:190) at org.colos.ejs.library.Animation.step(Unknown Source) at org.colos.ejs.library.Animation.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
I also tried x = _view.drawingPanel.getMouseX(); y = _view.drawingPanel.getMouseY();
and got a similar error message.
Do I need to import something before running this or build a custom class? Thank you for your patience. Bob