This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
There is very little difference between the way you would write an applet and a stand-alone application. The main differences are: Applets are typically embedded in a web browser, and the Applet class has been outfitted with some methods that allow the Applet to interact with that web browser in a minimal way. Furthermore, you do not ahve to perform the process of creating and showing the Applet, because the borwser does this for you. It's pretty trivial anyway.
Secondly, Applets have a methods that are called by specific browser events, which are typically part of the life cycle of an Applet. Since you are not using an applet, you can basically ignore these, all except one. Should you choose to use the init() method for any reason, you will need to manually invoke the init() method just after construction. Typically, rather than using the init() method (which isn't predefined for stand-alone applications anyway), you make a method called createAndShowGUI() which basically does the same sorts of things.
The sun microsystems tutorials for Applets and Swing are good places to start to understand the differences between applets and stand-alone applications (note: the Swing tutorial essentially teaches stand-alone desktop applications).
If you're planning on doing animation, you will also want to look into the following:
I've been searching for the same, but there's not that many good, all-in-one sites. The book I have is Java 2 Game Programming by Thomas Petchel. It is pretty good, but very basic. You'll only read about 5 or 6 chapters and the rest just teaches the basics of Java. The good thing, is it has a lot of simple, but really good examples.
I never used the Applet class, I always extend the JApplet class. I'm used to working with JFrames' where I call the getContentPane() method, then add in my JPanels, or whatever.
I consider extending JApplet similar to extending JFrame, but I don't think you can set a JApplets size(done in html code), and you dont need to bother with setVisible(true), or setLocation() or setDefaultCloseOperation, cause it wouldnt make sense in an applet.
I guess you would extend Applet, if you just wanted to paint directly to screen, not sure if you can JPanels when extending Applet
Originally posted by colin shuker: I guess you would extend Applet, if you just wanted to paint directly to screen, not sure if you can JPanels when extending Applet
Applet is part of the old AWT API. You would use Panel instead of JPanel if you wanted to go this route. However, I think using Swing (all the GUI classes that start with J) is the prefered method in more recent versions of Java.