NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
November 01, 2014, 03:50:20 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
An interdisciplinary approach. ...Wisdom
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: How come cannot assign yv[j] to POS Y of a text field?  (Read 7783 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Hero Member
*****
Offline Offline

Posts: 1729


http://weelookang.blogspot.com


WWW
«
Embed this message
on: August 27, 2009, 04:59:31 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=710.0

Hi prof,

i encountered a strange problem and i manage to isolate the cause.

The cause is
when i assign a yv[j] to the POS Y of a text field

it compile ok
but when i mouse over the array dots

the Ejs console starts to show error message. How to solve or overcome this problem? Thanks!



"RMI registry started at port: 2008
EjsConsole server is ready to listen at port: 2008
Running selected program
 C:/Program Files/Java/jre6//bin/java -Xmx256m -classpath bin/comSun.jar;bin/osp.jar;bin/ejs_lib.jar;bin/bsh.jar;bin/ejs.jar;bin/extensions/djep.jar;bin/locales.jar -Dcodebase=. -Dhome=D:\Shared\EasyJavaSimulation\EJS_4.2_090807\EJS_4.2\workspace org.colos.ejs.osejs.Osejs -lastFile -lookAndFeel javax.swing.plaf.metal.MetalLookAndFeel -decorateWindows -screen 0
cHotEqn V 4.02 cHotEqn
java.lang.reflect.InvocationTargetException
   at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.colos.ejs.library.control.MethodWithOneParameter.invoke(Unknown Source)
   at org.colos.ejs.library.control.GroupVariable.propagateValue(Unknown Source)
   at org.colos.ejs.library.control.EjsControl.doTheUpdate(Unknown Source)
   at org.colos.ejs.library.control.EjsControl.update(Unknown Source)
   at org.colos.ejs.library.Animation.update(Unknown Source)
   at org.colos.ejs.library.Animation.updateWhenIdle(Unknown Source)
   at org.colos.ejs.library.control.EjsControl.updateSimulationWhenIdle(Unknown Source)
   at org.colos.ejs.library.control.ControlElement.variableChanged(Unknown Source)
   at org.colos.ejs.library.control.displayejs.ControlPoligon.interactionPerformed(Unknown Source)
   at org.opensourcephysics.displayejs.AbstractInteractiveElement.invokeActions(Unknown Source)
   at org.colos.ejs.library.control.swing.ControlPlottingPanel.handleMouseAction(Unknown Source)
   at org.opensourcephysics.display.InteractivePanel$IADMouseController.mouseMoved(Unknown Source)
   at java.awt.Component.processMouseMotionEvent(Unknown Source)
   at javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
   at java.awt.Component.processEvent(Unknown Source)
   at java.awt.Container.processEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Window.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1

for example i didn't copy the whole chunk of error message


* bug03.PNG (24.14 KB, 923x258 - viewed 235 times.)

* bug04.PNG (114.45 KB, 1024x768 - viewed 263 times.)

*** There are 1 more attached files. You need to login to acces it!
« Last Edit: August 27, 2009, 05:07:13 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3057



WWW
«
Embed this message
Reply #1 on: August 27, 2009, 05:53:14 pm » posted from:Taipei,T\'ai-pei,Taiwan

Have you defined a variable "j" and assigned a proper value?
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1729


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #2 on: August 27, 2009, 08:15:38 pm » posted from:Singapore,,Singapore

it appears j is defined as a integer and assigned a number 0 in the variables page.



Any other possible insights?

by the way, what does the error message in ejs console by "java.lang.ArrayIndexOutOfBoundsException: -1" mean?

but the n is equal 11, should be enough? hmmmmmmmmmmmmmm


Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
   at users.sgeducation.lookang.weexvav17rebuildworkingold_pkg.weexvav17rebuildworkingold._method_for_showcoordinates_l2_y(weexvav17rebuildworkingold.java:510)
   ... 34 more
E


* bug05.PNG (25.6 KB, 591x582 - viewed 267 times.)
« Last Edit: August 27, 2009, 08:45:24 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3057



WWW
«
Embed this message
Reply #3 on: August 27, 2009, 09:57:38 pm » posted from:Taipei,T\'ai-pei,Taiwan

The error message I found is different from what you have shown.
I found there is a strange character at the end of last variable at first variable page: vti
I removed that character and it compiled without any error.
Please check out the attached file.


*** There are 1 more attached files. You need to login to acces it!
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1729


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #4 on: August 27, 2009, 10:09:35 pm » posted from:Singapore,,Singapore

U have to select in the drop down list edit v-t graph

move ur mouse over any of the green objects

the error continues to appear even on your attachment of my xml. Grin

by the way, i notice the time stamp is interesting, it is 11.09 pm instead of 10:09:35 PM
is the codes modified correctly? Grin
« Last Edit: August 27, 2009, 10:12:08 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3057



WWW
«
Embed this message
Reply #5 on: August 29, 2009, 03:44:46 pm » posted from:Taipei,T\'ai-pei,Taiwan

You can find out the following from ejs console:
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at users.lookang.weexvav17rebuildworkingold_pkg.weexvav17rebuildworkingold._method_for_showcoordinates_l2_y(weexvav17rebuildworkingold.java:624)

Open weexvav17rebuildworkingold.java (under output directory) check out line 624:
which is:
  public double _method_for_showcoordinates_l2_y () { return yv[j]; }

The problem is due to j has been assign a value which is not acceptable: for example: -1

for example: you assign Element property to j in ParticleSet_movable2
which mean that j will be assign value -1 when mouse is not move to those particles (not selected).
You might have other setting cause similar effect.

You can change the setting from yv[j]  to yv[jid]: and defind a new variable jid
add the following code at "Fixed Relation page)
if(j>-1 && j<n)jid=j;
else jid=0;// or other valid values.
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1729


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #6 on: August 29, 2009, 04:04:44 pm » posted from:Singapore,,Singapore

thanks a million, the cause of the problem was bugging me every day. I can't stop thinking about it. LOL

U helped me overcome this problem.

My reflection:
I roughly know it was the ArrayIndexOutOfBoundsException: -1 giving problem, but i didn't know -1 was a illegal state in java ArrayIndexOutOfBoundsException: -1, thus unable to overcome it myself. Grin I was trying many ways but just can't solve it alone.

Thanks!


*** There are 1 more attached files. You need to login to acces it!
« Last Edit: August 29, 2009, 04:10:41 pm by lookang » Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1729


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #7 on: December 01, 2009, 09:34:59 pm » posted from:Singapore,,Singapore

i have learnt how to solve the array out of bound error!!!!

i solved a problem on my own, reflecting on this post. Ya!.

i download any java editor, i google and http://www.jedit.org/index.php?page=download came up.

after installing

i browsed to the error file
LookangVernierCaliper04FKH.java for example
look for the error line it was, say line 803

with jedit is easy to locate that line,

for example the old code is //xp=xm2t[vs]; // this is the way to determine position of lower scale pointer

that means vs jumps to a illegal value from what was defined in the variable page

for my example xm2t is defined as an array n2t where n2t is defined as 11.


insert and modify logically . my example is

// adding this code to solve array out of bound error 803
// http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1183.0 solution discussed
if(vs > -1 && vs< n2t)vsidarray=vs;
else vsidarray=0;// or other valid values.

// this line is causing array out of bound error 803
//xp=xm2t[vs]; // comment that line that is causing the array out of bound error
xp=xm2t[vsidarray]; // modify logically to this

this way, no more array error out of bound 12 because n2t is 0 to 10.
cool!
« Last Edit: December 01, 2009, 09:58:17 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3057



WWW
«
Embed this message
Reply #8 on: December 02, 2009, 09:20:06 am » posted from:Taipei,T'ai-pei,Taiwan

Yes, you find out the way to debug the run time error when developing EJS simulation.

The java console will display the filename and line number where run time error occurs.
You will find the java file under EJS output subdirectory.

You can use any text editor to debug it (it will be better if the editor can display line number).

P.S. EJS can display syntax error in ejs console, but EJS can not find out run time error.
Logged
Pages: [1]   Go Up
  Print  
An interdisciplinary approach. ...Wisdom
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Visualizing electric field
Molecular Workbench
concord 0 10098 Last post August 21, 2005, 09:34:50 am
by concord
how to make the text b always appear after the simulation is reset?
Dynamics
lookang 16 12322 Last post July 26, 2007, 11:40:25 pm
by Fu-Kwun Hwang
problem with Ejs 4.2 new text objects cannot display "^o" as subscript string.
Questions related to EJS
lookang 3 4610 Last post October 04, 2009, 06:00:32 am
by fem@um.es
Electric field
Request for physics Simulations
Rare 5 5842 Last post October 05, 2009, 11:30:09 pm
by Rare
Ask about text informations
Question related to Physics or physics related simulation
ahmedelshfie 10 5861 Last post March 29, 2010, 09:22:37 am
by Fu-Kwun Hwang
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.062 seconds with 23 queries.since 2011/06/15