Thanks for asking your frequent question. I am giving you a sample of how to programme an applet of Henon-Heiles? Bellow I the example are a example.Hope that you will be get a benifit from it

Section 1
/* C: osc.c = solve anharmonic oscillator equation */
#define  dt (0.01)
#define  omega2 (1.0)
#define  beta (0.4)
double f(double x){
 return (-omega2*x-beta*pow(x,3));
void lf2(double x,double p,double *xn,double *pn,double h){
 double ph;  
 *xn=x+h*ph; *pn=ph+(h/2)*f(*xn);
void rk4(double x,double p,double *xn,double *pn,double h){
 double x1,x2,x3,x4,p1,p2,p3,p4;
 x1=h*p; p1=h*f(x);
 x2=h*(p+p1/2); p2=h*f(x+x1/2);
 x3=h*(p+p2/2); p3=h*f(x+x2/2);
 x4=h*(p+p3); p4=h*f(x+x3);  
 *xn=x+(x1+2*x2+2*x3+x4)/6; *pn=p+(p1+2*p2+2*p3+p4)/6;
int main(){
 double  x, p, xn, pn, energy;
 double  d, d1, d2;
 int     solver, n, max=800;
 FILE    *fp;
/* 4th order yoshida parameters */
 d1=1/(2-d); d2=-d/(2-d);
 /* choice of scheme */
 printf("Which algorithm? (1:Runge-Kutta,2:Leap Frog,3:Yoshida)");
/* initial condition */
 x=2.0; p=0.0;
 printf("First energy=%10.6f ¥n",energy);
/* file open */
 case 1:
   fp=fopen("rk4.dat","w"); break;
 case 2:
   fp=fopen("lf2.dat","w"); break;
 case 3:
   fp=fopen("ys4.dat","w"); break;
 fprintf(fp,"%10.7f  %10.7f¥n",x,p);
/* time development */
 for(n=1; n    switch(solver){
   case 1:/* Runge-Kutta */
   x=xn; p=pn; break;
   case 2:/* Leap Flog */
     x=xn; p=pn; break;
   case 3:/* Yoshida */
     x=xn; p=pn;
   x=xn; p=pn;
   x=xn; p=pn; break;
/* write data */
   fprintf(fp,"%10.7f  %10.7f¥n",x,p);
 }/* end of time development */
/* check of the energy conservation */
 printf("Final energy=%10.6f ¥n",energy);
/* end */
 return 0;

Section 2
/* Java: = Applet program with henon.html:

Henon-Heiles system

width=700 height=600>

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class henon extends Applet implements ActionListener, ItemListener,
 CheckboxGroup cbg=new CheckboxGroup();
 TextField tf=new TextField(15);
 Button btn1, btn2, btn3;
 Image img;
 Graphics bg;
 String msg;
 protected int width, height, ON=1, OFF=0;
 protected int xc=350, yc=350, scale=500;
 int SW, mx, my;
// variables
 int count, max=1000000;
 double dt=0.001, t, dd;
 double x1, x2, p1, p2, energy;
 double sx, sy;
 double[][] PS=new double[1000][2];// Poincar¥'e section
 public void init(){
 // canvas
   width=getSize().width; height=getSize().height;
 // items
   Checkbox cb1=new Checkbox("E=1/12",false,cbg);
   Checkbox cb2=new Checkbox("E=1/8",false,cbg);
   Checkbox cb3=new Checkbox("E=1/6",false,cbg);
   add(cb1); cb1.addItemListener(this);
   add(cb2); cb2.addItemListener(this);
   add(cb3); cb3.addItemListener(this);
   btn1=new Button("START");
   btn2=new Button("STOP");
   btn3=new Button("CLEAR");
   add(btn1); btn1.addActionListener(this);
   add(btn2); btn2.addActionListener(this);
   add(btn3); btn3.addActionListener(this);
 public void resetDisplay(){
 public void itemStateChanged(ItemEvent ie){
   String str=((Checkbox) ie.getItemSelectable()).getLabel();
     energy=1.0/12.0; t=0.0;
   }else if(str=="E=1/8"){
     energy=1.0/8.0; t=0.0;
   }else if(str=="E=1/6"){
     energy=1.0/6.0; t=0.0;
 public void actionPerformed(ActionEvent ae){
   if(ae.getSource()==btn1){// START
     SW=ON; calc();
   }else if(ae.getSource()==btn2){// STOP
   }else if(ae.getSource()==btn3){// CLEAR
     for(int i=0; i<1000; i++){
       PS[i][0]=0.0; PS[i][1]=0.0;
 public void mousePressed(MouseEvent me){
   mx=me.getX( ); my=me.getY( );
     return;// out of bounds
       tf.setText("x2="+x2+", p2="+p2);
       tf.setText("No Good, Try again!");
 public void mouseClicked(MouseEvent evt){ }
 public void mouseReleased(MouseEvent evt){ }
 public void mouseEntered(MouseEvent evt){ }
 public void mouseExited(MouseEvent evt){ }
 public void paint(Graphics g){
   int vx, vy;
   for(int i=0; i<1000; i++){
     vx=xc+(int)(scale*PS[i][0]); vy=yc+(int)(scale*PS[i][1]);
// potential energy
 public double V(double x1, double x2){
   return ((x1*x1+x2*x2)/2+x1*x1*x2-x2*x2*x2/3);
// right hand sides
 public double f1(double x1, double x2, double p1, double p2){
   return (p1);
 public double f2(double x1, double x2, double p1, double p2){
   return (p2);
 public double f3(double x1, double x2, double p1, double p2){
   return (-x1-2*x1*x2);
 public double f4(double x1, double x2, double p1, double p2){
   return (-x2-x1*x1+x2*x2);
// for use of Poincar¥'e section
 public double g1(double x1, double x2, double p1, double p2){
   return (1/p1);
 public double g2(double x1, double x2, double p1, double p2){
   return (p2/p1);
 public double g3(double x1, double x2, double p1, double p2){
   return ((-x1-2*x1*x2)/p1);
 public double g4(double x1, double x2, double p1, double p2){
   return ((-x2-x1*x1+x2*x2)/p1);
 public void calc(){
   double x1_1, x1_2, x1_3, x1_4, x1n;
   double x2_1, x2_2, x2_3, x2_4, x2n;
   double p1_1, p1_2, p1_3, p1_4, p1n;
   double p2_1, p2_2, p2_3, p2_4, p2n;
   double dx, t_1, t_2, t_3, t_4;
     for(int i=0; i        x1_1=dt*f1(x1,x2,p1,p2);
       if((x1<0)&&(x1n>0)){ /* Poincar¥'e section at x1=0 */
         PS[count][0]=x2n; PS[count][1]=p2n; count+=1;
       x1=x1n; x2=x2n; p1=p1n; p2=p2n;

Section 3
# Perl: = KdV equation according to Zabusky-Kruskal scheme
use Tk;
sub init{
# constants
 N=200; h=2.0/N; dt=0.0001;
 delta=0.022; c_uux=dt/(3*h);c_uxxx=(delta**2)*dt/(h**3);
# initial condition
   uold[j]=cos(PI*x); u[j]=uold[j];
# start
sub run{
# display
   xx=100+3*j; yy=400-u[j]*100;
# computations
 for (1..40) {
 # periodic boundary condition
 # renewal
     uold[j]=u[j]; u[j]=unew[j];
 $canvas->after(1, ¥&run);

Section 4
# Python: = 2dim. BZ reaction-diffusion equation
import Tkinter
import time
from numpy import *
from math import *
# canvas
# model N x M: PBC
N, M=30, 60
# parameters
dt, h=0.01, 0.1
DX, DY=0.0001, 0.0001
A, B=1.0, 3.0
maxX, maxY=0.0, 0.0
minX, minY=6.0, 6.0
# preparation
X=zeros([N+2, M+2],float)
Y=zeros([N+2, M+2],float)
XX=zeros([N+2, M+2],float)
YY=zeros([N+2, M+2],float)
rhsX=zeros([N+2, M+2],float)
rhsY=zeros([N+2, M+2],float)
for j in range(N+2):
 for k in range(M+2):
   s, t=pi*j/N, pi*k/M
diagX, offX=1-4*DX*dt/h2, DX*dt/h2
diagY, offY=1-4*DY*dt/h2, DY*dt/h2
# nonlinear reaction terms
def SX(u,v):
 return (A-(B+1)*u+u*u*v)
def SY(u,v):
 return (B*u-u*u*v)
# coloring
def floatRgb(mag, cmin, cmax):
 # normalize to [0,1]
   x = float(mag-cmin)/float(cmax-cmin)
 # cmax = cmin
 blue = min((max((4*(0.75-x), 0.)), 1.))
 red  = min((max((4*(x-0.25), 0.)), 1.))
 green= min((max((4*math.fabs(x-0.5)-1., 0.)), 1.))
 return (red, green, blue)
def strRgb(mag, cmin, cmax):
 red, green, blue = floatRgb(mag, cmin, cmax)      
 return "#%02x%02x%02x" % (red*255, green*255, blue*255)
# main
def run():
 global X, XX, Y, YY, rhsX, rhsY, maxX, maxY, minX, minY
 # show color table
 for j in range (256):
   color=strRgb(float(j), 0.0, 256.0)
 # find maxX, maxY, minX, minY
 for j in range(1, N+1):
   for k in range(1, M+1):
     if maxX        maxX=X[j][k]
     if maxY        maxY=Y[j][k]
     if minX>X[j][k]:
     if minY>Y[j][k]:
 # display
 for j in range(1, N+1):
   for k in range(1, M+1):
     x, y=6*(j-1), 20+6*(k-1)
   # coloring
     color=strRgb(X[j][k], minX, maxX)
     color=strRgb(Y[j][k], minY, maxY)
 # run 10 times
 for i in range(5):
   for j in range(1, N+1):
     for k in range(1, M+1):
       rhsX[j][k]=dt*SX(X[j][k], Y[j][k])
       rhsY[j][k]=dt*SY(X[j][k], Y[j][k])
       XX[j][k], YY[j][k]=rhsX[j][k], rhsY[j][k]
   for j in range(0, N+2):
     XX[j][0], XX[j][M+1]=XX[j][M], XX[j][1]
     YY[j][0], YY[j][M+1]=YY[j][M], YY[j][1]
   for k in range(0, M+2):
     XX[0][k], XX[N+1][k]=XX[N][k], XX[1][k]
     YY[0][k], YY[N+1][k]=YY[N][k], YY[1][k]
   # rename
   X, Y=XX, YY
 canvas.after(1, run)

Still if you have any question please post here.