Applet FAQ

I think an applet FAQ would be awesome. It would be great also to have a section just dedicated to applets as their a lot of special considerations like bugs, tutorials, sizes, offline testing, focus. It seems like java for games could really take off by taking some of the flash market share.

As a beginner here are a list of the questions I have. I’ve answered what I’ve could, but I’m sure there are a ton more.

Flash v Java: advantages and disadvantages?

Warning! Reading this part might be a bit depressing, depending on your current time investment of Java. Flash is the king of the browser game market despite being proprietary and not as flavorful, smooth as Java.

http://www.java-gaming.org/index.php/topic,19373.0.html

Browser Penetration: (Portability of Java is practically meaningless by looking at this stat)
http://www.statowl.com/java.php Penetration: 54% with 1.6 + 19% with 1.5. Total 73%.
http://www.statowl.com/flash.php Penetration: 54% with 9. + 40 with 10. Total 94%

On a positive side, Java is going to allow you to move toward bigger and more complex games.

What size should my applet be?

According to this site, the most common browsing resolution as of March 2009 is 1024x768. I used Photoshop on Windows XP to measure the maximum available browsing height with tabs and task bar up: On Firefox I only had 535 pixels. (Width seems mostly irrelevant.)

According to the flash discussion <a href="http://www.triquitips.com/viewtopic.php?f=25&t=617>here, 640x480 seems to be the preference. Of course with vector graphics, flash may have more flexibility.

According to this <a href="https://www.mochiads.com/community/forum/topic/portals-and-game-sizes-list-of-portals-max-size>discussion that lists several flash portals, 640x480 is the max for a few but many go much larger. Width doesn’t seem to be much of an issue, often set at 800.

Beware of large file sizes as it will hurt performance.

Why is the size of the applet important?

Try playing this amazing <a href="http://www.rocksolidarcade.com/games/robokill/>game on low resolution like 1024.

Webstart versus Applet?

Consensus says applet; however both do different things. Applets should be great for in browser gaming with fast loading and keeping the visitors harddrive clean. Webstart is great for keeping a game up-to-date and cleaning installing your application. The full discussion can be found <a href="http://www.java-gaming.org/index.php/topic,20044.0.html>here.

How to double buffer with an applet?

I’ve found three code samples I like. It would be wonderful if a Java Guru could chime in on the quality of these.

http://www.naturalprogramming.com/javagui/BeatingHeartApplet.java

http://www.gamedev.net/community/forums/topic.asp?topic_id=405663

http://www.gamespp.com/java/gameProgrammingTutorial04.html

Which Java game frameworks support applets?

Slick
LWJGL
PulpCore
3DzzD
GTGE
http://www.jpct.net/forum2/index.php/topic,1247.0.html
JOGL --> Unknown.
(any others?)

How do I test my applet offline?

AppletViewer

In an IDE, just add it to a frame. Something like this:


 public static void main(String[] args) {
        SampleApplet applet = new SampleApplet();
        Frame frame = new Frame();
        frame.addWindowListener(new WindowAdapter()
        {
          public void windowClosing(WindowEvent e)
          {
            System.exit(0);
          }
        });

        frame.add(applet);
        frame.setSize(800,600);
        frame.show();
        applet.init();
        applet.start();
    }

In a browser, for a single class,

<applet code="SampleApplet.class" width="800" height="600"></applet>

In a browser, from a Jar:

<applet code="SampleApplet.class" archive="SampleJar.jar" width="800" height="600"></applet>

How to add files (images and sound) to a JAR?

In NetBeans, right click on the project. Select properties. Select the category named “Sources.” Click “Add Folder” under the Source Package Folder Section. Select your directories. The default is .. Hit okay.

How to load files (images and sound) from a URL?

(need help)

How to load files (images and sound) from a jar on a URL?

(need help)

How to setup your code to load from a hard drive or URL?

(need help)

What is the best sound player for uncompressed files?

Use AudioClip. Clip seems to be buggy.

What is the best sound player for compressed files like Ogg and MP3?

(need help)
How do I add my own art to the Java Loading screen?

https://jdk6.dev.java.net/plugin2/#LOADING_SCREEN

How can I drive traffic to my game?

<a href="http://jayisgames.com/>http://jayisgames.com/
<a href="http://www.123spill.no/>http://www.123spill.no/
http://www.javagametome.com
http://digg.com/
http://www.greatgamesexperiment.com/games/

Where can I attempt to sell my game to a portal?

http://www.heavygames.com/
http://www.freearcade.com/


http://www.arcadepod.com/java/

Not interested in money, just want to get the game out there to be played.

http://gamejolt.com
http://www.jars.com/
http://www.javashareware.com/

What are the know bugs?

Mac users have a tough time with 1.6.

Is there an explanation of the major browser crash bug? I know David Brackeen’s framework resolves this but his code was a bit over my head.

What is the difference between Applet and JApplet? Which to use?

On person says, Applet is the HeavyWeight component, just use Applet everywhere and forget about JApplet.

However, when I use a canvas for double buffer and use Applet, I get a nasty 8 pixel bar along the top of my application. JApplet does not have this issue.

Has Oracle’s purchase of Sun doomed Java Games?

How to write to a server for things like high scores, save data, etc?

This allows folks to communicate with perl etc on the server side.

http://www.javaworld.com/javatips/jw-javatip34.html

I agree!

<applet code="SampleApplet.class" archive="SampleJar.jar" width="800" height="600"></applet>

good idea :slight_smile:

[quote]What is the difference between Applet and JApplet? Which to use?
[/quote]
Applet is the HeavyWeight component, just use Applet everywhere and forget about JApplet

[quote]Which Java game frameworks support applets?
[/quote]
Hey what about 3DzzD ! :stuck_out_tongue: (work everywhere Java 1.1)

[quote]How do I test my applet offline?
[/quote]
AppletViewer

[quote]What size should my applet be?
[/quote]
you can in some case have performance issue with a too big Applet

[quote]Webstart versus Applet?
[/quote]
as I am an Applet addict I will say that Webstart just sucks … forget and use Applet

[quote]Sending a HTTP POST
[/quote]
http://www.javaworld.com/javatips/jw-javatip34.html

hiya, thanks for posting. Could you tell me what types of things this is used for? highscore writing?

o yeah, its nice to know because of sending stuff to say a php script that then posts to a database. :wink: so yes highscore writing, player data saving etc… jit allows a server-side php/perl/script to receive data from the applet.

[quote]Which Java game frameworks support applets?
[/quote]
GTGE too. Very easy to create applets, have made about 7-8 with no problems.

Quite a lot of the other questions would depend on the framework used. For example, using GTGE to play a .wav I use playSound, playMusic for Midi, without using a framework would load an AudioClip (wth main class extending Applet).

Offline testing still use a browser (Firefox mainly).

[quote]Which Java game frameworks support applets?
[/quote]
jPCT also. http://www.jpct.net/forum2/index.php/topic,1247.0.html

here are some severals free sounds :
http://www.pacdv.com/sounds/voices-2.html

http://ebiz.u-aizu.ac.jp/~paikic/lecture/2005-1/handout/Chap13.pdf

sorta covers a little of everything on applets.

GTGE also supports .mp3 thats what i currently use. I have a question regarding applets soon my game will cross the 10mb threshold should this be a concern regarding actually playing the game once loaded?
When the game is finally finished i intend to share the client and .bat file to run it as an app as a torrent(can you get a mac and linux version of a .bat ? please message me if you can ;D).
I keep hearing about mysql/php/applet whats wrong with mysql/java application on serverside/applet ?
I can put highscore data directly onto the applet (if i could find away of actually calculating what decides who goes on top any one help here?).

I haven’t done stuff with applets for ages but isn’t the whole automatic prompt for installation a good thing? as flash has? Wasn’t there some way to nest embedded object and applet together that it works in all browsers and if running firefox or IE automatic installation of the plugin?

since it’s seems to be still in the docs, just using applet tag doesn’t get you that, some hints here:
http://java.sun.com/javase/6/docs/technotes/guides/jweb/applet/applet_deployment.html

[quote]I keep hearing about mysql/php/applet whats wrong with mysql/java application on serverside/applet ?
[/quote]
Nothing wrong, guess the issue is more people have php supported hosting than java server hosting (as until recently been loads cheaper!).

I was refering to the fact of having to learn another language.I suppose i didnt see it from the side of whats being provided by the host server machine.

I would say yes. I’d try to limit it to under 10 for sure, targeting around 5. Some nice sfx could replace mp3s. I was finding mp3s take up way too much space. I did a poll one time and a surprising number of people prefer their own music while playing. Many turn the sound off all together playing at work and what not.

i would say that the pros definitely make it the best.

what is the difference between Applet and Japplet?

major difference is that Applet works …

AWT / Swing

JME also supports applets.

I wouldnt quite agree :P. basically JApplet, is applet with a few extra bells and whistels. I mean it even EXTENDS it :stuck_out_tongue: