View Full Version : Java code --> Applet using Xcode: Help!

Feb 20, 2008, 01:59 PM
Ok, I've never used Xcode before until now. For school, I've been writing all my programs in vi. Now I need to turn some code into an applet. It's basically a simple game with a GUI front already put on it that I can run from the command line. Now I want to turn that into an Applet. I've been clicking stuff and moving it around in Xcode trying to see some progress, but to no avail. I've also tried using Apple Launcher, but it doesn't do anything for me. So what I need help with is simple: how do I take these 4 .java files and make an applet out of them in Xcode? (or some other IDE recommendation. I've used Eclipse once...) I'm using OS X 10.5.
Thanks for any help!

Feb 20, 2008, 02:25 PM
You need to create a Java Applet Xcode project. Choose File > New Project to create a new project. A window with a large list of project types will open. Go to the Java section to see the Java project types. If you're using Xcode 3, select a Java Applet project. I don't have an earlier version of Xcode to verify, but I believe earlier versions of Xcode had AWT and Swing applet projects. You would select the appropriate project, depending on what toolkit you used to create your GUI.

After creating your project, add your .java files to the project by choosing Project > Add to Project.

Feb 20, 2008, 05:29 PM
Ok, yea I think I had gotten that far. Well, as far as making a new Java Applet project and adding my .java files. But now I don't know how to make the file with the main method to run. It keeps running that "hello world" demo applet. Oh, and it's in Swing, which for some reason has trouble loading for me in Safari and Mozilla.

Feb 20, 2008, 06:20 PM
Why does it fill my new project with demo crap? It's kind of annoying. Also, does anyone know why I can't view a Swing based Applet in any of my web browsers?

Feb 20, 2008, 06:39 PM
I've written a few applets, and didn't use Xcode to do it. Simple enough from the command line.

Feb 20, 2008, 06:51 PM
Ok, so give up on Xcode. I know I need to make the class extend JApplet, and add the init() method, which would "replace" the constructor, but I'm not quite sure what to do with the constructor code and all the JPanel and JFrame variables. Leave them there?
I still don't know why I can't test a Swing applet (simple ones) in a web broswer. I just get the red X.

Feb 20, 2008, 07:47 PM
I can't tell from here either.