Ok, I am somewhat newbie to java and need help with what is "possible," so I know what to learn.
Ok, I want to make a STAND-ALONEapplet with a java swing interface with it. What I mean is, I do not want my applet in a browser, instead I want it to be a downloadable app, where to user double-clicks the game icon in windows, and the game will pop up in a window like this:
Well is it possible to have an interfce like this with an applet there? And also, I would want it so, if the user were to click on a certain area, it would pop-up a swing-interface window, and there, the user and generate a "world" for the game using the window, then it would close and return use of the applet. [ July 22, 2006: Message edited by: Keenan Staffieri ]
Yes, absolutely. What you're talking about is an "application." An "applet" has a very specific meaning in Java -- a chunk of code of a certain type that is specifically intended to run inside a Web browser. Although they were important when Java was first introduced, they are a little-used niche technology now.
Here is Sun's Swing GUI tutorial; most of the examples -- including the very first one -- are applications, not applets.
Yet I am confused because the swing code looks a lot like the 2d applet stuff. And I wanted to know, if its possible to code a 2d game just like I would with an applet. Like, can I basically just start my game off with applet code, but have the swing interface with this?
I guess the only change would be the way the init() method for the applet works.
Ok, my wording is confusing lol, yes you are right... an application. You see my current position right now, is that I recently got the book "Beginning Java 5 Game Programming" and it teaches me APPLETS. It talks as if I want it in a broswer, but I don't. So is it ok to continue to learn applet? Because it seems like I should be able to "mix" the swing interface with applet-like code?
author and iconoclast
The difference between an applet and an application is pretty easy to describe. An Applet extends java.applet.Applet, and implements the Applet methods (init(), start(), stop(), destroy()) and the browser calls them. Most applet-writers override init() and maybe start(), and that's it. The browser always calls init() first, and then start(). The Applet is itself a graphical component -- you can draw on it, attach buttons to it, etc.
In an application, you don't have to extend anything in particular. You write a "main" routine
and when you start your program, it gets called. If you want a GUI in an application, you have to create one, usually by creating an instance of JFrame. If you want to paint, you write a class that extends JPanel, override paintComponent(), and add your JPanel to the JFrame.
Aside from these differences, everything else is the same. The Java2D API, the Swing libraries -- all these are available in your application, just as they are in an applet.
Joined: Jul 22, 2006
so an app will still allow animation, just like an applet would, and create polygons and rectangles is exactly the same, and you can manipulate them the same?
author and iconoclast