Lesson 6: Creating animation Points and Activities.
Points and Activities Using off-screen image to avoid screen-flushing. Creating off-screen image and copying it to the real screen. Drawig on the off-screen. Creating animation Example 6. import java.awt.*; import java.applet.*; import java.awt.event.*; public class Exm6 extends Applet implements ActionListener { Button button1 = new Button(); // Plot Button Button button2 = new Button(); // [...]
Tags: Creating animation Points and Activities
Lesson 5: Changing parameters.
Points and Activities How to move figures interactively Rounding off numbers Exm5.java import java.awt.*; import java.applet.*; import java.awt.event.*; public class Exm5 extends Applet implements ActionListener { Button button1 = new Button(); Button button2 = new Button(); Label label1 = new Label(); int vxmin,vymin,vxmax,vymax; //screen coordinates double xmin,ymin,xmax,ymax; //imaginary coordinates double dx; //interval of x double [...]
Tags: Changing Parameters
Lesson 4: Calculating Sequences.
Points and Activities Buttons TextFields Labels. Events. Transforming integer string. Transforming double string. Example 4 1+2+3+4+….+n. Exm4.java import java.awt.*; import java.applet.*; import java.awt.event.*; public class Exm4 extends Applet implements ActionListener { TextField textField1 = new TextField(); //input textField TextField textField2 = new TextField(); //output textField Label label1 = new Label(); Label label2 = new Label(); [...]
Tags: Calculating Sequences
Lesson 3: Drawing graphs of functions.
Points and Activities How to create a “method”. Type and parameter of method. method for transforming coordinate Example 3 Graphs of functions Exm3.java import java.awt.*; import java.applet.*; public class Exm3 extends Applet { int vxmin,vymin,vxmax,vymax; //screen coordinates double xmin,ymin,xmax,ymax; //imaginary coordinates double dx; //interval of x /* initializing */ public void init(){ xmin=-5;xmax=5;ymin=-3;ymax=7; vxmin=0;vxmax=300;vymin=0;vymax=300; dx=0.1; [...]
Tags: Graphs of Functions
Lesson 2: Drawing curves.
Points and Activities. Double and integer Casting Changing colors Math objects Utilizing coordinates Example 2 Lissajous figures. Exm2.java import java.awt.*; import java.applet.*; public class Exm2 extends Applet { public void paint(Graphics g) { int t; //angle (degree) double tt; //angle (radian) int x1,y1,x2,y2; //two points g.setColor(new Color(255, 255, 192)); //back color g.fillRect(0,0,300,300); g.setColor(Color.black); //color of [...]
Tags: Drawing curves
Lesson 1: How to make applets.
Activities Compiling Java source files and HTML files Basic structure of java source files for-next sentences Screen coordinates Example 1 Drawing line design Exm1.java import java.awt.*; //use all awt package import java.applet.*; //use applet package public class Exm1 extends Applet //declaration of class { public void paint(Graphics g) //paint method { int x; //variable x [...]
Tags: Lessons
