Page 1 of 1

Lesson4

Posted: Mon Aug 31, 2020 9:21 am
by admin
From now on we will use the ready-made library Open Source Physics Core Library.
You should download this library using the next link
https://easy-english-study.com/osp.jar
and include it in NetBeans everytime before compiling projects
Open NetBeans and right-click on the project name in the Projects tab.
Select Properties.
Select Libraries.
Click the Add Jar/Folder button.
classpath.png
classpath.png (32.11 KiB) Viewed 2093 times
Navigate to the directory where the downloaded osp.jar file is.

Re: Lesson4

Posted: Mon Aug 31, 2020 9:23 am
by admin
Create the project PlotFrameApp.

Re: Lesson4

Posted: Mon Aug 31, 2020 9:59 am
by admin
  1. package plotframeapp;
  2. import org.opensourcephysics.frames.PlotFrame;
  3. public class PlotFrameApp{
  4. public static void main (String[] args){
  5. PlotFrame frame=new PlotFrame ("x","sin(x)/x","Plot example");
  6. for (int i=1; i<=100; i++){
  7. double x=i*0.2;
  8. frame.append (0,x,Math.sin(x)/x) ;
  9. }
  10. frame.setVisible(true) ;
  11. frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
  12. }
  13. }

Re: Lesson4

Posted: Mon Aug 31, 2020 9:59 am
by admin

Code: Select all

package plotframeapp;
import org.opensourcephysics.frames.PlotFrame;
public class PlotFrameApp{
public static void main (String[] args){
PlotFrame frame=new PlotFrame ("x","sin(x)/x","Plot example");
for (int i=1; i<=100; i++){
double x=i*0.2;
frame.append (0,x,Math.sin(x)/x) ;
}
frame.setVisible(true) ;
frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
}   
}

Re: Lesson4

Posted: Mon Aug 31, 2020 10:25 am
by admin
The screenshot of PlotFrameApp program.

Re: Lesson4

Posted: Mon Aug 31, 2020 10:36 am
by admin
This program draws points of the function sin(x)/x using the library osp.jar.