Applet fails to display in certain browsers

Started by
2 comments, last by frob 15 years, 5 months ago
I have an applet that may or may not work depending on which browser it is running on and how the html file was run. I am usually able to get applets to run on any browser in any circumstance. From the beginning: I am writing a network game in which the server-side runs in a java application and the client-side runs in an applet. When the applet first opens it, it goes to a screen asking you to enter in the IP address of the server. When you enter it, it connects to the server and starts the game. I ran the client through a batch file and ran the server through Appletviewer and it worked perfectly. I put a shortcut to the html file on the desktop and double-clicked on it (so it would use my default web browser, firefox), and it worked perfectly. When opened up firefox separately and opened the html file, it did not work. It went to the IP address input screen. When I entered the IP address, the applet looked like it froze, but the server application was still receiving button presses and mouse clicks from the applet like it should. I minimized and unminimized the browser, and it just showed a gray background, but it was still sending the user inputs to the server. Because it worked when I double-clicked on the desktop file, I know that the code is good. And because it sent the button presses and mouse clicks, I know that the paint() method is being called. So, I think that maybe something is wrong with the Graphics object sent to the paint() method. I tried it on a variety of browsers in a variety of ways: Setting the default browser and double-clicking on the html file: firefox - works ie - sends data but fails to display properly opera - fails to connect to server, remains on the IP address input screen, opera does not close properly and must be closed with task manager safari - works Open the browser, then open the file: firefox - sends data but fails to display properly ie - sends data but fails to display properly opera - sends data but fails to display properly safari - works Right-clicking on the html file on desktop and selecting "Open with...": any browser - sends data but fails to display properly I simply cannot figure out why any applet would behave this way, or how someone would start to go about fixing it. Any ideas?
Advertisement
The first thing to do is to look at the Java console in the browser and see what output the applet generates. In Firefox it's in the tools menu.

You can then debug it by sending more output to the console to find out what's going on.
Thanks.

I now know that there is a fileNotFoundException when I create a FileReader for a text file. Now I need to figure out why that would occur when I open it from firefox but not from the desktop.

Maybe the permissions differ from the different ways of getting to file.
Quote:Original post by WolfgangZenger
Thanks.

I now know that there is a fileNotFoundException when I create a FileReader for a text file. Now I need to figure out why that would occur when I open it from firefox but not from the desktop.

Maybe the permissions differ from the different ways of getting to file.

Yes they are different.

Applets have very different security considerations than local apps, and cannot do anything with files, including read or write, unless the user specifically give them permissions.

This topic is closed to new replies.

Advertisement