Can see in appletviewer but not in browser

Hy,

I am trying to display a text on JTextArea using the code below. In appletviewer this is OK but I can not see the text on browser (IE 6, NS 8, Firefox 1.0.7). The browser only show a retangle applet. No exceptions.

If I insert this two lines

output = " \nHy";

outputArea.append( output );

then I can see "Hy" but not the text in mytext.txt. Why?

Thanks

Flow

import java.io.*;

import java.awt.Container;

import javax.swing.*;

publicclass myClassextends JApplet{

publicvoid init(){

JTextArea outputArea =new JTextArea();

outputArea.setLineWrap(true);

outputArea.setWrapStyleWord(true);

outputArea.setEditable (false);

Container container = getContentPane();

container.add(new JScrollPane( outputArea ) );

String output ="";

String file ="mytext.txt";

try{

BufferedReader bufR =new BufferedReader(new FileReader(file));

String s =null;

while ((s = bufR.readLine()) !=null){

output += s;

}

bufR.close();

}catch (Exception e){

e.printStackTrace();

}

outputArea.setText(output);

}

}

<html>

<head>

<title>Untitled Document</title>

</head>

<body>

<applet code="myClass.class" width="300" height="80"></applet>

</body>

</html>

[2497 byte] By [FreeFlowa] at [2007-10-2 6:21:44]
# 1

in your Java Console, while runnig your applet on browser you'll se...

Java Plug-in 1.5.0_04

Usar versi髇 JRE 1.5.0_04 Java HotSpot(TM) Client VM

Directorio local del usuario = C:\Documents and Settings\mbaiges

java.security.AccessControlException: access denied (java.io.FilePermission mytext.txt read)

at java.security.AccessControlContext.checkPermission(Unknown Source)

at java.security.AccessController.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkRead(Unknown Source)

at java.io.FileInputStream.<init>(Unknown Source)

at java.io.FileInputStream.<init>(Unknown Source)

at java.io.FileReader.<init>(Unknown Source)

at myClass.init(myClass.java:24)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

That's because an applet needs to be a "signed applet" to have the requested privileges to access to local files, such as your "mytext.txt".

There are many topics related to this problem that will help you to solve it :-)

inudora at 2007-7-16 13:23:33 > top of Java-index,Desktop,Core GUI APIs...
# 2
ThanksFlow
FreeFlowa at 2007-7-16 13:23:33 > top of Java-index,Desktop,Core GUI APIs...