mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 05:39:18 +01:00
poo
This commit is contained in:
73
processing/app/ProcessingAppletViewer.java
Normal file
73
processing/app/ProcessingAppletViewer.java
Normal file
@@ -0,0 +1,73 @@
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
|
||||
public class ProcessingAppletViewer implements Runnable {
|
||||
ProcessingApplet applet;
|
||||
Thread killer;
|
||||
//int portnum;
|
||||
//Socket umbilical;
|
||||
//OutputStream umbilicalOut;
|
||||
//InputStream umbilicalIn;
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
try {
|
||||
//portnum = Integer.parseInt(args[1]);
|
||||
//umbilical = new Socket("localhost", portnum);
|
||||
|
||||
new ProcessingAppletViewer(args[0],
|
||||
Integer.parseInt(args[1]),
|
||||
Integer.parseInt(args[2]));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ProcessingAppletViewer(String name, int x1, int y1) throws Exception {
|
||||
Class c = Class.forName(name);
|
||||
applet = (ProcessingApplet) c.newInstance();
|
||||
applet.init();
|
||||
applet.start();
|
||||
|
||||
Window window = new Window(new Frame());
|
||||
window.setBounds(x1 - applet.width, y1, applet.width, applet.height);
|
||||
window.add(applet);
|
||||
applet.setBounds(0, 0, applet.width, applet.height);
|
||||
window.show();
|
||||
applet.requestFocus(); // necessary for key events
|
||||
|
||||
//umbilical = new Socket("localhost", portnum);
|
||||
//umbilicalOut = umbilical.getOutputStream();
|
||||
//umbilicalIn = umbilical.getInputStream();
|
||||
|
||||
killer = new Thread(this);
|
||||
killer.start();
|
||||
}
|
||||
|
||||
|
||||
File deathNotice = new File("die");
|
||||
|
||||
public void run() {
|
||||
//while (Thread.currentThread() == killer) {
|
||||
while (true) {
|
||||
if (deathNotice.exists()) {
|
||||
deathNotice.delete();
|
||||
System.exit(0);
|
||||
}
|
||||
//try {
|
||||
//System.out.println("testing");
|
||||
//umbilicalOut.write(100);
|
||||
//umbilicalIn.read();
|
||||
//} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
//System.exit(0);
|
||||
//}
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user