NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => Collaborative Community of EJS => Topic started by: lookang on August 13, 2008, 10:14:50 pm



Title: Physlets Electric field lines one positive and one negative charge java applet
Post by: lookang on August 13, 2008, 10:14:50 pm
http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=730.msg2704#new





Physlets®, i.e., the Java applets themselves, are a registered trademark of Wolfgang Christian.  


Title: Re: Electric field lines generated by one positive and one negative charge applet
Post by: Fu-Kwun Hwang on August 15, 2008, 12:07:04 am
Simulations created with Physlet library need javascript to generate actions.
You can not just add applet tag(It would not work, unless you did not need to add any objects or actions).
Please check out the html source from generated physlet simulations and you will find those javascript code.
And when you submit message, the forum  will change line break(RETURN:which is not visible) into html line break code.
So (RETURN) will add some code in the applet tag or javascript. You will need to remove it.
And the physlet classes are located at "/classes/" at this web site.




Click in the simulation regin to draw field line which will pass the click point.


Title: Re: Electric field lines generated by one positive and one negative charge applet
Post by: Fu-Kwun Hwang on August 15, 2008, 07:45:28 am
http://home.phy.ntnu.edu.tw/~lookang/Physletbuilder/Efieldgeneratedbyonepositiveandonenegativecharge.html

PS:
i have to delete this applet here, cos only can display one :)


Please check out  Electric field structure and Field lines for two point charges +/- (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=539.0) for similar applet created with EJS.



Title: Re: Electric field lines generated by one positive and one negative charge applet
Post by: jeff_forssell on August 15, 2008, 01:59:55 pm
I may be "knocking down an open door" but I just want to point out that many of the Physlet applets can be used even without Javascript code. in the applet on this page there is the
<param name="ShowControls" value="false">
If that is set to "true" instead, the page visitor will see a control panel and be able to create and change objects.

But the true power of Physlets is the ability to create situations that can be easily manipulated (by the visitor pressing a button or changing a value) to show the things one wants to show.


Title: Re: Electric field lines generated by one positive and one negative charge applet
Post by: Fu-Kwun Hwang on August 15, 2008, 04:49:32 pm
Yes. I am agree with that "Physlet can be created without javascript".
Advanced user can use it to manually generate different kind of simulations.


Title: Re: Electric field lines generated by one positive and one negative charge apple
Post by: lookang on August 15, 2008, 10:56:47 pm
is it possible to create custom control checkbox to show (true/false) for global properties like field lines, forces etc ?

currently, when i enable the control, the default control appears


Title: Re: Electric field lines generated by one positive and one negative charge applet
Post by: Fu-Kwun Hwang on August 15, 2008, 11:47:34 pm
The physlet is a java library designed to be controled with java-script.
So you can add java-script to add different effect you want.
You will need to know about basic javascript coding and you also need to read physlet document to know what javascript functions are available. (You can download/view document from physlet home site).

Let me know you some examples: (I also add the same code to the first message.)

Check out the above physlet applet after you click the button.

If you click edit checkbox in the simulationBuilder page.
You will find out the javascript code being generated with that builder.
The builder only support basic functions in physlet library. Many complicated functions were not implemented with the builder (Because I create the builder for beginner to create simple simulation. And I do not have time to create complicate graphical user interface--- I am not a professional programmer.)


Title: Re: Electric field lines generated by one positive and one negative charge apple
Post by: lookang on August 16, 2008, 08:23:07 am
amazing... i followed your scripts to make this!



Title: Re: Electric field lines generated by one positive and one negative charge applet
Post by: Fu-Kwun Hwang on August 16, 2008, 08:57:54 am
Good! you are a quick learner!
The beauty of physlet is to be able to use javascript to change different behavior at run time.
Actually, you can also use javascript to call build in functions or user defined functions (or variables) in EJS generated simulations to change simulation at run time.


Title: Re: Electric field lines generated by one positive and one negative charge applet
Post by: lookang on August 20, 2008, 03:57:10 pm
The codebase in the applet tags point to the URL for browser to find java classes files.
And javascript can use the nameor id tag in the applet to referer to applet.

value for the name is :Efield2
and the following javascript:
fkh2=document.Efield2;
will referer to the applet.
So fkh2.setAutoRefresh(false); will execute setAutoRefresh function defined in the applet.

Why there is no reference of the url of http://home.phy.ntnu.edu.tw/~lookang/Physletbuilder/Efieldgeneratedbyonepositiveandonenegativecharge.html ?.. is this calling my files ? or is it part of your website library ?

Thanks! ;D


Quote
var timerID2=0; function initApplets2(){ clearTimeout(timerID2); loaded2=true;timerID2=setTimeout("init2()",100);}function init2(){fkh2=document.Efield2;fkh2.setAutoRefresh(false);fkh2.setDefault();id1=fkh2.addObject("charge","x=-0.2,y=0,q=-1,r=10");fkh2.setShowFieldLines(true);id2=fkh2.addObject("charge","x=0.2,y=0,q=1,r=10");fkh2.setLabel(id1,"-");fkh2.setLabel(id2,"+");fkh2.setAutoRefresh(true);} <applet width="640" height="480" code="eField4.EField.class" codebase="/classes/" archive="EField4_.jar,STools4.jar" align="baseline"  name="Efield2" mayscript>
i remove the script and applet tags because even in code tags, the applet appears and jam (prevent the top applet from working properly) the top applet :'(


Title: Re: Electric field lines generated by one positive and one negative charge applet
Post by: Fu-Kwun Hwang on August 21, 2008, 10:25:14 pm
codebase="/classes/"

Mean it is using library at the same web site(where the web page is located!).
 If you want to use library at other web site  you need to add something like
codebase="http://home.phy.ntnu.edu.tw/~lookang/classes/"

Each applet should have it's own name , if you add another applet tag with the same name in your previous post, the browser did not know which one to act on. That is the reason why it was not working.

You need to write special code to show applet tag instead of insert another applet into the message.

type & lt; (without space between & and lt;)to show <


Title: Re: Electric field lines generated by one positive and one negative charge apple
Post by: lookang on August 25, 2008, 10:20:38 pm
so it is using your jar files!!

i tried to link up with mine in http://home.phy.ntnu.edu.tw/~lookang/classes/

i cannot understand why it works on my pc but after uploaded onto the http://home.phy.ntnu.edu.tw/~lookang/classes/ it didn't work anyway.

i suspect the files names changed the need to change Efield_.jar from EField_.jar ;D


Title: Re: Electric field lines generated by one positive and one negative charge applet
Post by: Fu-Kwun Hwang on November 11, 2008, 08:58:28 pm
http://home.phy.ntnu.edu.tw/~lookang/classes/ does not exist.
but http://home.phy.ntnu.edu.tw/~lookang/Physletbuilder/classes/ exists.
You did not provide the correct file path.