aspose file tools*
The moose likes Beginning Java and the fly likes looking for non-applet science simulations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "looking for non-applet science simulations" Watch "looking for non-applet science simulations" New topic
Author

looking for non-applet science simulations

Bill Stanard
Greenhorn

Joined: Oct 10, 2005
Posts: 12
For my programming students, I'm looking for non-applet (and non-JApplet) science simulations written in java. Most simulations seem to be in applet or JApplet format. Any suggestions on where to look for simulations that would be interesting to programmers and science (physics, chemistry, biology, et cetera) students?

cheers!
Bill

<wstanard@palmertrinity.org>
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Why non-Applet?

Most Applets and JApplets can be run as applications with the addition of a suitable main() routine:



As I said, this will work for many applets -- but not all.


[Jess in Action][AskingGoodQuestions]
Bill Stanard
Greenhorn

Joined: Oct 10, 2005
Posts: 12
Assuming a simple applet such as the following...

...where do I add the code that you suggest? Or do I rewrite my code to fit the pattern that you suggest? Sorry to be so thick...
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

The important part of this is the main() method. I showed inside an entirely separate class, but you can just take the "public static void main() { ... }" part and put it into the WelcomeApplet class itself. Change "TheApplet" in my code to "WelcomeApplet", compile the applet, and then run the result with

java WelcomeApplet

from the command line.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Of course, if you don't want to "pollute" your applet class, you can use Ernest's example as a separate class in a separate file basically as it is.

Layne


Java API Documentation
The Java Tutorial
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18108
    
  39

Is the "appletviewer" option still available? That use to be my favorite option to run applets from the command line.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Bill Stanard
Greenhorn

Joined: Oct 10, 2005
Posts: 12
Thanks, Ernest & Layne,
It works... but... I need to grab and then resize the frame before it shows anything (in the case of the WelcomeApplet, the helloLabel). Any idea why this is? I've noticed it a lot with some of the applets I write, that text fields or labels are quite often hidden until the applet (frame) is grabbed and resized. Then all is well.
cheers!
Bill
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Because the components are added after the applet is visible on the screen; the LayoutManager needs a special notification that you're done changing the screen before it actually does anything. You should be able to fix this by moving the init() call to just before the setVisible() call -- I suppose I've misled you in not doing it that way in the first place.
 
Consider Paul's rocket mass heater.
 
subject: looking for non-applet science simulations
 
Similar Threads
refactoring topic for undergraduate thesis?
Applet and XML Doc through a browser
put an applet into a web page
Applet not Running!
Applet - Swing