This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

looking for non-applet science simulations

 
Bill Stanard
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bill Stanard
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Henry Wong
author
Marshal
Pie
Posts: 20892
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the "appletviewer" option still available? That use to be my favorite option to run applets from the command line.

Henry
 
Bill Stanard
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic