Code: http://www.zuidaima.com/share/1852345677564928.htm
Text: Java Swing implements the code for a small ball moving along a sinusoidal curve
Package Com.zuidaima.swing;import Java.awt.*;import javax.swing.*;p ublic class Sinrun extends JFrame implements Runnable {static int i = 0;static int j = 250;static Double x = 0;static Double v = 10;//speed static Double w = 2 * MATH.PI; static double A = 50;//amplitude static Double t = 0;//time public sinrun () {this.setsize (n); this.setvisible (true);} public void Paint (Graphics g) {super.paint (g); G.setcolor (Color.Black); G.filloval (I, j + (int) x, 10, 10);} public void Run () {while (true) {try {thread.sleep;} catch (Interruptedexception e) {//E.printstacktrace ();} i + = V;x = A * Math.Cos (w * t); t + = 0.1;this.repaint (); if (i >) i = 0;}} public static void Main (String args[]) {New Thread (new Sinrun ()). Start ();}}