File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Game Development and the fly likes Need Knowing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "Need Knowing" Watch "Need Knowing" New topic
Author

Need Knowing

Keenan Staffieri
Greenhorn

Joined: Jul 22, 2006
Posts: 23
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-ALONE applet 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:

-------------------------
File Options About......|
-------------------------
800*600 java applet here|
........................|
........................|
........................|
........................|
........................|
------------------------|
Bottom bar..............|
-------------------------

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 ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi,

Welcome to JavaRanch!

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.


[Jess in Action][AskingGoodQuestions]
Keenan Staffieri
Greenhorn

Joined: Jul 22, 2006
Posts: 23
Thank you for the reply,

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?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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

public static void main(String[] args)

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.
Keenan Staffieri
Greenhorn

Joined: Jul 22, 2006
Posts: 23
ahh ok

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?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Absitively.
Keenan Staffieri
Greenhorn

Joined: Jul 22, 2006
Posts: 23
ok, ty, sorry for all question, but im noob and needed assurace
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Keenan Staffieri:
ok, ty, sorry for all question, but im noob and needed assurace


That's exactly what this forum is for. Please come back with more questions.

Layne


Java API Documentation
The Java Tutorial
 
 
subject: Need Knowing
 
Similar Threads
close pop up window from servlet
Need urgent Help - Browser is hanging
How to give the Target of pop-up window form as a frame in the main window
Popup lists
Launch default web browser from swing