|
-
November 19th, 2009, 11:01 AM
#1
Problem with an applet
Hi,
I am building a little game and it works fine as an application but when I build it as an applet something strange happens. When I run the applet in Eclipse I don't see the whole applet but just a part of it. The missing part is image icons... Well, it's a bit more complicated: I have special class which extends Jlabel and on the labels I have image icons and status fields which can be of type int and are needed for easier implementation of my game. So I don't see exactly that objects of the extended JLabel class with images on it. When I create a HTML file and put the applet, I see just a gray rectangle and nothing else. In Eclipse I see at least the stuff that isn't of object of my label class. Any idea who it is so and how can I fix it?
Thanks!
-
November 19th, 2009, 02:53 PM
#2
Re: Problem with an applet
Are you reading the images from disk? Applets run in a security 'sandbox', which means they are not permitted to read from or write to the client machine. Check the Java console for security exception messages.
See What Applets can and can't do, Applet Security, etc. Google 'java applet security' for more.
Any programming problem can be solved by adding a level of indirection...
Anon.
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
November 19th, 2009, 03:15 PM
#3
Re: Problem with an applet
I was reading them from the disc but after I tried to read them like this nothing happened and I see absolutely nothing now:
Code:
private static URL url;
private static Toolkit tk = Toolkit.getDefaultToolkit();
private static Image image;
private void setURL()
{
try{
url = new URL("http://img136.imageshack.us/img136/8159/something.jpg");
} catch (MalformedURLException VariableDeclarationID) {}
image = tk.getImage(url);
}
and then invoke the above method in the constructor.
How do I make it read it not from the disc and not from a website???
Last edited by Berisades; November 19th, 2009 at 03:22 PM.
-
November 19th, 2009, 03:55 PM
#4
Re: Problem with an applet
So what does the Java console say? Does it show any error messages?
Why do we never have time to do it right, but always have time to do it over?
Anon.
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
November 19th, 2009, 03:59 PM
#5
Re: Problem with an applet
It doesn't say anything bad. Well, I figured out the problem - removed static from the URL. Now the problem is how to get the URL of my images and use them without uploading them separately on the Internet? And even one more problem: I see the applet in Eclipse but again, I don't see it in the browser.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|