/*
This class is a basic extension of the Applet class. It would generally
be used as the main class with a Java browser or the AppletViewer. But
an instance can be added to a subclass of Container. To use this applet
with a browser or the AppletViewer, create an html file with the
following code:
Simple
You can add controls to Simple with Cafe Studio.
(Menus can be added only to subclasses of Frame.)
*/
import java.io.*;
import java.awt.*;
import java.applet.*;
import java.net.*;
public class HelloWorld extends Applet implements Runnable {
URL babble;
int globalx, globaly;
double r;
Thread anima;
String s="";
int dx, dy, s_index=0, offset;
public void init() {
super.init();
//{{INIT_CONTROLS
setLayout(null);
resize(283,190);
label1=new Label("A sim pull Applet", Label.CENTER);
add(label1);
label1.reshape(68,75,147,15);
anima = null;
DataInputStream d = null;
try {
babble = new URL(getDocumentBase(), "HelloWorld.java");
d = new DataInputStream(babble.openStream());
String ts;
while((ts=d.readLine()) != null)
{
s = s+ts;
}
} catch (Exception e) {System.out.println("HI "+e);};
// System.out.println(s);
//}}
}
public boolean handleEvent(Event event) {
return super.handleEvent(event);
}
//{{DECLARE_CONTROLS
Label label1;
//}}
public boolean mouseDown(Event e, int x, int y)
{
double r1 = Math.random(); double r2 = Math.random();
if (anima != null) anima.stop();
anima = new Thread("dwawing");
anima.start();
r = r1+r2;
globalx = x; globaly = y;
repaint();
return true;
}
public boolean mouseDrag(Event e, int x, int y) {
dx = globalx-x; dy=globaly-y;
globalx = x; globaly = y;
Graphics g = getGraphics();
repaint();
return true;
}
public void run() {
while (true) {
offset = (offset-2)%250;
repaint();
try { Thread.sleep(100); } catch (Exception e) {}
}
}
public void paint(Graphics g) {
int flip=0;
Polygon poly = new Polygon();
g.setColor(Color.white);
Rectangle b = bounds();
g.fillRect(0,0,b.width,b.height);
g.setColor (Color.green);
g.fillOval(globalx,offset+globaly,250,30 );
g.setColor (Color.red);
g.drawRect(0,0,size().width, size().height);
g.setColor(Color.black);
g.drawLine(0,0,20,20);
g.fillOval( 20, 20, 35, 35 );
g.setXORMode(Color.white);
// s_index = 0;
int i;
for (i =0; i < 20; i++) {
for (int j=0; j<25; j++) {
g.drawRect(i*10, j*10, 5, 5);
for (int k=j; k