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 (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
- 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 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.