MASON-INTEREST-L Archives

November 2005

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Sean Luke <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Tue, 29 Nov 2005 13:07:44 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (69 lines)
Hi Randy.

Applets have security restrictions.  Unless you sign them and the
user gives special permissions, they cannot read a file on a user's
computer.  However, they can read files from the remote computer --
but not using FileReader.  This is because FileReader reads files on
hard drives, and the applet, when running, is no longer *on* the
remote server's computer -- it's on the client's computer.

Instead, generally you can get applet files fetched from the remote
server using getResource and getResourceAsStream (see the class
'java.lang.Class').  This can also be used to grab files when the
program is running as a program and not an applet.

BTW, your code does not run on Mac browsers: likely again it's been
compiled with a bytecode too recent for Java 1.4.2 (OS X's default
Java for web browsers).  Please try recompiling it using
     javac -target 1.3 ...
[or same in jikes]

Sean

On Nov 29, 2005, at 12:59 PM, RDLatimer wrote:

> We're doing a Sugarscape-type project.
> The background sugarscape world is read in with a sugarscape.txt file.
> This works as an application, but doesn't seem to work as an applet.
>
> Go here:
> http://www.tjhsst.edu/~rlatimer/modeling/ychen/SugarScape2.html
>
> I have a screenshot of the intended look - the yellow background
> for the
> sugarworld.
>
> If you run the applet model, there is no background?
>
> Both of the files listed - SugarScape2.java and RuleG2.java
> read the data file - sugarfield.txt (from the sugarfield method)
>
> try{
>    FileReader fileReader = new FileReader("sim/app/sugarscape/
> sugarfield.txt");
>    BufferedReader sugarfield = new BufferedReader(fileReader);
>  ...
>
> This version works as an application (we see the background)
> java -classpath myMason2.jar:. sim.app.sugarscape.SugarScapeWithUI2
>
> The applet version doesn't show the background.
>
> Here's the applet code from the .html file:
>
> <p>
> <applet code="sim.display.SimApplet.class" archive="./MyMason2.jar"
> height="30" width="300">
> <param name="CODE" value="sim.display.SimApplet.class">
> <param name="type" value="application/x-java-applet;version=1.1">
> <param name="ARCHIVE" value="./myMason2.jar">
> <param name="Simulation" value="sim.app.sugarscape.SugarScapeWithUI2">
> <param name="Name" value="SugarScape Model">
>
> </applet>
> <p>
>
>
> Thanks, Randy Latimer
>

ATOM RSS1 RSS2