![]() |
![]() T540 Spring Semester 2002 |
Here's a second way of doing double buffering:
import java.awt.*; import java.applet.*; class fNFA extends Applet { private Image offScreenImage; private Graphics offScreenGraphics; private Dimension offScreenSize; public final void update(Graphics theG){ Dimension d=size(); if( (offScreenImage == null) || (d.width != offScreenSize.width) || (d.height != offScreenSize.height)) { offScreenImage = createImage(d.width, d.height); offScreenSize = d; offScreenGraphics = offScreenImage.getGraphics(); } offScreenGraphics.clearRect(0, 0, offScreenSize.width, offScreenSize.height); paint(offScreenGraphics); theG.drawImage(offScreenImage,0,0,null); } }
This gives you a no-flicker applet.
Now your code needs only start from it.
Today in class I would like to start from the following files:import java.applet.*; import java.awt.*; public class SimulOne extends fNFA implements Runnable { // instance variables public void init() { // whatever initializaton we need to do } Thread simulation; // let's just assume public void start() { if (simulation == null) { simulation = new Thread(this); } simulation.start(); } public void paint(Graphics g) { // simply do your painting } public void stop() { // irrlevant, just to match the start above if (simulation != null) { simulation.stop(); simulation = null; } } public void destroy() { } // not really needed... public void run() { while (true) { // your simulation loop, time passes... } } }
/u/dgerman/public/javaa3d.zip
/u/dgerman/public/examples1_6.jar
/u/dgerman/public/J3DJumpStart.zip
http://developer.java.sun.com/developer/onlineTraining/java3d/
http://web3dbooks.com/java3d/
Now let's do networking.
Then we look at our other chat. Here's the server side of it:
We used it once. Today we will try to use it by telnet-ing into it.
Here's a session with the server:
Here's one of the clients' session:burrowww.cs.indiana.edu% java ChatServer 39999 Server successfully initialized. Waiting for connection... Received New Connection. Got: login||adrian from null Got: say||How are you people? from adrian Received New Connection. Got: login||michael from null Got: say||hola, who else is on-line? from michael Got: say||I am here, Michael, how are you? from adrian Got: logout from michael Got: logout from adrian ^Cburrowww.cs.indiana.edu%
And here's the other one:frilled.cs.indiana.edu%telnet burrowww.cs.indiana.edu 39999 Trying 129.79.245.98... Connected to burrowww.cs.indiana.edu. Escape character is '^]'. login||adrian login||adrian||adrian has entered the room. list||adrian say||How are you people? say||adrian says: How are you people? login||michael||michael has entered the room. list||adrian&michael say||michael says: hola, who else is on-line? say||I am here, Michael, how are you? say||adrian says: I am here, Michael, how are you? logout||michael has left the room. logout Connection closed by foreign host. frilled.cs.indiana.edu%
Please note that these sessions are intertwined:frilled.cs.indiana.edu%telnet burrowww.cs.indiana.edu 39999 Trying 129.79.245.98... Connected to burrowww.cs.indiana.edu. Escape character is '^]'. login||michael login||michael||michael has entered the room. list||adrian&michael say||hola, who else is on-line? say||michael says: hola, who else is on-line? say||adrian says: I am here, Michael, how are you? logout logout||michael has left the room. Connection closed by foreign host. frilled.cs.indiana.edu%
adrian
connected
michael
connected
michael
disconnected
adrian
logged out too
Here's that, done with RMI, for your edification.
Here, now, are what has been received thus far in terms of project proposals:
Two more links, also for discussion.
And Sue Menzel's Shakey!