Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Knowing

 
Keenan Staffieri
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Keenan Staffieri
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Absitively.
 
Keenan Staffieri
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, ty, sorry for all question, but im noob and needed assurace
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic