My applet displays part of the screen behind it - java

So when I alt-tab between the applet and something else, may it be another window or just the desktop, the applet ends up looking like this when I come back to it:
This is the Embed gadget I use on the google site I host my applet on. Normally it would just be my applet, but it shows the stuff that I had recently alt-tabbed away from.
It also does this in Eclipse's applet viewer. Not just this applet, but every applet I've made (which is why I don't think it has anything to do with the code of this applet in particular).
Is this a problem related to the way I write my paint() method, or is it something else?

Related

Made a .jar file of an app I made using JFrame in java. Which works 100%. But when I have it loading from a website, its just a blank white screen

So as I tried to describe in the title.
I made an application that works 100% when compiled, and also when opened with the .jar file I made for it.
So my next step was to run this from my online portfolio. However, when I use the
<APPLET ARCHIVE="xxxxx.jar" CODE="xxxxx.class" WIDTH=400 HEIGHT=300>
</APPLET>
approach... So the Applet prompts me to run, I click Yes. My JFrame pops up like it normally would, however it is just a completely white blank screen. ( no content from my app )
I must have them linked appropriately if the JFrame even loads at all. So I'm not sure whats up.
Any help? Thanks
Edit: I forgot to mention, I am running this locally at the moment. Not sure if they would have anything to do with anything.
What method would I use to upload a .jar file to be executed from a web page?
For deploying Java desktop apps., the best option is usually to install the app. using Java Web Start. JWS works on Windows, OS X & *nix.

Applet lifecycle when out of focus

Does a Java Applet always execute its code even when it losts focus? I've to put this applet in a web page.
I'm tryng to understand this cause i've to develop an applet that listen to some hardware components through JavaPos. I have a callback method defined inside the applet and i'm not sure if it works even when users click on other page component.
Thanks
Does a Java Applet always execute its code even when it losts focus?
Yes, unless of course the applet code intentionally stops execution on loss of focus.

Turning java application into applet

I followed a tutorial for a bit of learning java 2d gaming. It included turning it into an applet.
I use a class which is the launcher class, and it basically just launches it. It can be run as applet (using init) or an application (with main)
I expanded upon the code greatly, Adding a save and load feature using a flat .txt and .png files. which used get_property("user.home") and so forth.
Now I know that applet's on the browser can not save/view the persons computer information. So the above is useless for an applet.
What I have tried doing is commenting and adjusting everything that includes the persons computer information and so forth, And I still can not get the applet to load.
I am using dropbox to host it, I have tried different browsers and made sure the applet was not loaded into my cache for changes I did.
The applet in my eclipse IDE works fine-even saves, so I can't trust it, so I am using dropbox.
My applet did work, this was a long time ago before I developed the engine into my game.
I will share my GameHandler class because it holds the meat of the game. I really should organize this better. Any suggestions?
http://pastebin.com/zdmexGya GameHandler class.
I'm positive saveGame and loadGame do not even get called.

JFileChooser in a slick2d applet

In my project I have a JFileChooser to select the path of which you want to save/load a world from. My project works great when running as an application but when it's on my website (an applet), it glitches.
See, what happens is everything works fine and the file chooser window pops-up BUT when you come to click on it, it does nothing. It's static, you can't type anything, use any keys. Here's an image of what I see.
http://ghostid.net/ran/popupExample.png
I literally have to open task manager and close Java for my browser to work again. Any idea what might be causing this? Why does it work as an application but not as an applet?
I signed my jars too... Could Slick2D be interfering with it? Is the focus stuck on the slick applet?

Applet is empty with absolute layout

I want to create a hangman game as an applet, so I have some labels and buttons that will be initialized by the generated code of the gui designer but I also have some labels I create on my own, after knowing how long my word is. Therefore I use absolute layout for my applet.
In netbeans my applet works finde when I run it but when I try to run it in the browser (I tried Firefox and IE) nothing is on the display, the applet is empty.
can someone help me with that?
Here you can find the source if it is helpful
http://root.xelluloid.de/Hedgeman/Hedgeman.java
With kind regards
Sebastian
Did you look at the Java console for the browser? It likely contains something that says that the program crashed because it could not find the AbsoluteLayout class.
This is for an older version of NetBeans, but the same should apply: http://forums.sun.com/thread.jspa?threadID=597783
I just had the same trouble with an applet and AbsoluteLayout and netbeans 7.1.
Everything works fine but errors are thrown when the applet runs from a browser.
I solved this by switching, in the form designer, from AbsoluteLayout to "Free Design" (which seems to default to GroupLayout in the code that is actually generated) but offers similar functionality (widgets can be placed without restrictions, borders, or even on top of others).
You could probably include the AbsoluteLayout Class/jar into your project and continue using this code. But in my case the code can't exceed 32KB and needs to be self contained (single file) as it needs to be uploaded to a small embedded device.

Categories

Resources