Sign in to follow this  
alexxzius

[java] applet questions

Recommended Posts

ok, a few noob questions: 1. How do u read and write files when running an applet. I tried using the buffered-stream-stuff and it just flooded me with errors. Is it even possible to make an applet use files? (probably has to do with security or something). 2. My game speed acting weird. For example, my game runs about 50% faster on Firefox than on IE. When i disable my wireless connection, my games speeds up like crazy. When i change the speed from 30 to 40 it slows down. But on 50 its running slower than on 40. I know if yo computer is from 19th century some things run slow cause CPU is 100+ but my CPU is 20%.

Share this post


Link to post
Share on other sites
1. You should be able to read files okay from an applet... you have to go through the URL to get at the file as opposed to hard coding a file path into a File object... I know that one hit me.

2. You got the same JVM in both browsers? One may be like 1.2.x and the other may be like 1.4.x or something like that... MS java vs Sun Java... it also depends on how you are timing your frames... if it's off of a timer class, that may be it.


Just things to look for... I don't know for sure... I'm new.

Share this post


Link to post
Share on other sites
Quote:
Original post by alexxzius
1. How do u read and write files when running an applet. I tried using the buffered-stream-stuff and it just flooded me with errors. Is it even possible to make an applet use files? (probably has to do with security or something).


Have you signed your applet? You need to sign it in, so that the user may choose whether or not to allow your applet access.

Quote:
Original post by alexxzius
2. My game speed acting weird. For example, my game runs about 50% faster on Firefox than on IE. When i disable my wireless connection, my games speeds up like crazy. When i change the speed from 30 to 40 it slows down. But on 50 its running slower than on 40. I know if yo computer is from 19th century some things run slow cause CPU is 100+ but my CPU is 20%.


Bacon and Eggs has some great points, check them out. Make sure your dynamics is time-based and not frame-based.

Share this post


Link to post
Share on other sites
Quote:

Have you signed your applet? You need to sign it in, so that the user may choose whether or not to allow your applet access.


Well obviusly i dont know how to sign an applet because if i did i would be able to read and write files. How do u sign applets anyways? (what function to use? i could just go and look it up myself)

A thing about speed i found out is that when the amount of sleep time is odd the applet runs faster.
sleep(29) runs faster than sleep(26). Weird . . .

Another question:
When i draw strings on my applet with /n and /t, they dont show up (just ignored)
So if my string is
String mystr="Multiline \nstring";
its displayed like
Multiline string

Share this post


Link to post
Share on other sites
ok, ive looked through several java books and didnt find nothing about how to sign an applet. The sun tutorials had a few pages about it but it didnt work.
I used the policytool in the command line and created a policy file and done all it said but it didnt work.
Any help ? . . .

Share this post


Link to post
Share on other sites
im working with applets for now. And i wanna know how to sign an applet not a jar or a webstart . . .
Signing is a complete and pointless redundance. Why not just allow working with files instead of going through all these. Its like sun corp saying "if u 2 dumb to figure out how to sign an applet, u shouldnt use files . . . ".

I figure you gotta tell an applet what policyfile to use or something.

Share this post


Link to post
Share on other sites
The only way to sign an applet is to put it in a jar.

The reason for it is for the users saftey. If they allowed unsigned applets to do anything, then anyone could just come in and wipe out your hard drive or anything. It is a measure of security.

Share this post


Link to post
Share on other sites
You shouldn't sign you applet because you're asking the user
to trust you to not trash his machine. Smart users will say
no.

Applets can read files using URLs that access the same server
as the applet was loaded from. Applets being developed can
read files on your development machine using FILE: Urls if
your permissions are set appropriately.

Applets can read directories from your host machine, but they
typically see the directory in the HTML format that your browser
would display for the same URL, some parsing is required.

Applets can also open socket connections back to the original
host, which is how games get run.

Share this post


Link to post
Share on other sites
ok, so I put my applet in a jar, but the browser wont display it. It gives me a bunch of Unknown Source errors (?).
The HTML code is

<applet code=applet1.class archive=applet1.jar width=400 height=300 >

I figured out how to make applet read files through URLs, but still dont know how to write files. . .
::skull::

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this