MiniSim is a Java/Swing program that I threw together as a demonstration of a networked simulation client. Alas the simulation networking component itself can't be shared with the public, but important themes were that the client was separable from the simulator, and that the networking parts of the client could be swapped out or removed, so that the fun little game-like part can be shared publicly. I suppose that really just turns this program into a demonstration of Java/Swing GUI implementation, but what the heck, it's fun to play with (well, briefly anyway). Click the screenshot below to start the applet and play with it.
The other thing that MiniSim may be useful in demonstrating is for creating a single piece of Java code that can run as both an independent on-screen application and as an applet situated on a webpage. So you can run MiniSim either by entering at the command-line:
> java -jar MiniSimDemo.jar
or by bringing up the webpage MiniSim.html in a window of a web browser that supports Java (that webpage in turn calls up MiniSimDemo.jar). Any modern browser should support that, but just in case, you can always get a Java plug-in at http://www.java.com. Either way, the Java applet/application should run right from the provided jar file.
The source code is available in my GitHub MiniSim repository. MiniSim essentially consists of two halves: the graphical user interface (GUI) that we see on the screen, and the simulator interface that keeps track of the numerical values for the various objects being simulated and communicates these values back and forth with other simulators. A UML class diagram for the program is seen below (and I must credit ArgoUML for its handy open-source UML diagramming ability). The classes related to the GUIFrame are on the left, and the classes associated with the simulation interface SimInterface are on the right. They're both instantiated from the main MiniSim class. The GUIFrame is updated and redrawn every quarter of a second or so (or however often one likes) by the AnimTimer. Before redrawing its time slider and little submarines on its map display, GUIFrame asks the latest values for those things from the SimInterface, which runs as a separate thread and updates itself at some different rate by the SimTimer (generally faster than the GUI updates). The GUIFrame also accepts some input, like mouse-clicks for new sonobuoy drops, which it passes on to the SimInterface.
The SimInterface is the key to a networked simulation implementation. MiniSim gets from its SimInterface the time and an up-to-date list of the positions, speeds, and so on from each NavalObject (like submarines and sonobuoys) participating in the simulation. The NavalObjects might be local in the same Java program instance on the same computer, or they might be running on some remote computer. The Submarine and Sonobuoy objects specified locally within this example code are very rudimentary in terms of their motion and sensing abilities, but the SimInterface could alternately take the Submarine and Sonobuoy information from more complicated simulators running outside of MiniSim, providing their information either via simple network sockets or a more involved simulation framework, to the SimInterface. My original hope with this public demo code was to create a simple socket framework in the SimInterface so that two MiniSim instances on the same LAN could automatically find each other via sockets and send the sub and sonobuoy info to each other in a "Battleship" game-like demonstration. Each "player" would not see the other's sub but each would deposit sonobuoys into the field that ping when sensing the other's sub. Alas I never implemented that part. Still, the thing operates on its own and lets you deposit sonobuoys which report sensing the sub while it drives around. So again it's a GUI/simulation demonstration rather than a fun game to play with (well, or you'd have to be REALLY bored!).