PDA

View Full Version : Blank applet


mixmaster
06-05-2009, 02:11 PM
not sure if this goes here... sorry if I misplace this.

Ok, I have a program we're writing in class... it is a brick-breaker game (you have a few rows of bricks, a paddle, and a ball that bounces around breaking the bricks).

There is a lot of stuff I have left to do on it, and only a short time left to work on it.

SO, I wanted to take it home.

When I put it on my computer at home though, everything compiles fine, and I get no errors when I run it... and yet, it only shows up as a white box like this:

http://www.theoldbreed.com/imagehosting/10424a26db2c41890.jpg

Now, the Imports we're using are from a .zip file we were given called "acm"... To run the program in school, we had to go to "SETTINGS ------> PATH / CLASSPATH -------> WORKSPACE --------->CLASSPATHS (tab) -----------> NEW -----------------> BROWSE..." and then find the acm.zip file. Once we did that, it was good to go.

My teacher let me take everything related to the program home with me to work on here.

I did all the above, and I still get the blank applet (I'm using the EXACT same program from school, the EXACT same program thing to write the program [JGRASP] on the same version as at school, and I have the EXACT same items, files, etc... as at school).

Is there anything else I need to do to get this to work?

mixmaster
07-14-2009, 03:47 AM
bump...

ckeyrouz
07-14-2009, 04:50 PM
In task bar at the bottom right, there is a small java icon that appears whenever you run your applet.

right click on it and select open console and you will see there the errors.

if you cannot find the problem by checking these errors post them here and we will see what we can do .

mixmaster
07-16-2009, 04:57 PM
I did that and the consol was blank.

when I compile and run a program in JGRASP, it has a field at the bottom that lists errors... there are no errors that it can find.

lbarowski
07-17-2009, 04:26 AM
Are you using the same Java version at school and at home?

IIRC the framework in the acm libraries makes each project runnable as either an application or an applet. If that is still the case, does your program run correctly as an application on your home system?

Anyway, you could start by putting print statements at points in the program where things are supposed to happen and trace down where it is getting "stuck". Or you could just debug the applet using jGRASP and use the debugger to find out the same thing. Of course, not knowing how the internals of the acm classes work could make it difficult to find the problem.

mixmaster
07-17-2009, 10:14 PM
ok... this is REALLY WEIRD.

I am running dual monitors (various reasons. One as my main, the other as a blank monitor so that I can drag stuff over there and view multiple things at the same time).

When I run the applet, it comes up on the main monitor as seen above... blank.

BUT, here's the weird part... when I move it over to my other monitor, IT SHOWS UP! and when I move it back to my main monitor, IT'S STILL THERE!

please help with THAT!

I'm so confused.

I tried getting rid of one monitor, and changing primary monitor and stuff, but that doesn't work.

lbarowski
07-17-2009, 11:09 PM
How about if you just iconify and de-iconify appletviewer?

Try one of the graphics demos from http://jtf.acm.org/demos/acm.graphics/index.html and see if it has the same problem. If not, then maybe you can compare your code and theirs to see if there is some crucial difference. If it does have the same problem, then you should report the issue to the ACM Java Task Force (java-task-force@cs.stanford.edu). Fist though, run the program in appletviewer from the command line and verify that the problem happens outside of jGRASP.

mixmaster
07-17-2009, 11:29 PM
here... i recorded what is happening.

check it out:

http://www.youtube.com/watch?v=PqaPQ2CJAt8

**edit**

same thing happens with the website demos.

lbarowski
07-18-2009, 12:46 AM
OK, so make sure the problem also happens when running with appletviewer from the command line (and there's no reason it shouldn't, jGRASP just calls appletviewer), then report the problem to the JTF. It's most likely a bug in their graphics library.

mixmaster
07-18-2009, 12:54 AM
OK, so make sure the problem also happens when running with appletviewer from the command line (and there's no reason it shouldn't, jGRASP just calls appletviewer), then report the problem to the JTF. It's most likely a bug in their graphics library.

ok.

I'm still pretty new to this stuff, so uh... how do i run it in "appletviewer"

lbarowski
07-18-2009, 04:14 AM
Create an HTML file in the same directory as your class file (or the root package directory, if your class is in a package), with contents like:

<applet code = "MyClass.class"
width = 400
height = 400>
</applet>

where "MyClass" is the name of your applet class. Then run appletviewer from the command line. Change to the directory containing the html file and run like:

"C:\Program Files\Java\jdk1.6.0_10\bin\appletviewer.exe" -J-cp -Jacm.jar test.html

Most likely you have not added the Java "bin" directory to your system path, so you will need the full path to appletviewer - change that based on whatever Java version you have. "test.html" would be whatever you named the html file. Also, I'm assuming you're using the "acm.jar" file for the acm libraries, even though you said "acm.zip" above, since acm.zip is the source distribution.

mixmaster
07-18-2009, 05:16 AM
where "MyClass" is the name of your applet class. Then run appletviewer from the command line. Change to the directory containing the html file and run like:

"C:\Program Files\Java\jdk1.6.0_10\bin\appletviewer.exe" -J-cp -Jacm.jar test.html

Most likely you have not added the Java "bin" directory to your system path, so you will need the full path to appletviewer - change that based on whatever Java version you have. "test.html" would be whatever you named the html file. Also, I'm assuming you're using the "acm.jar" file for the acm libraries, even though you said "acm.zip" above, since acm.zip is the source distribution.

i went to C:\Program Files\Java\jdk1.6.0_10\bin\appletviewer.exe

when I clicked on applet viewer... a command prompt screen blinked up for less than a second, then disappeared.

what's that mean?

mixmaster
07-18-2009, 05:23 AM
ok...

i made the html thing, put it in the same directory as everything else, and when I clicked on it... it came up as this:

http://www.theoldbreed.com/imagehosting/10424a61401063840.jpg

lbarowski
07-18-2009, 06:35 AM
The browser probably won't run it because of the acm.jar. Run it using appletviewer from the command line as I suggested above.

mixmaster
07-18-2009, 07:27 PM
The browser probably won't run it because of the acm.jar. Run it using appletviewer from the command line as I suggested above.

I tried doing that, but when I clicked on appletviewer, it'd pop up for less than a second and then disappear.

lbarowski
07-19-2009, 07:06 AM
Ah, "command line" means you open a "Command Prompt" in Windows and type in the command. The "cd" command will allow you to change the current directory first to the one containing your class and html files.