applet notinited in IE5.5
843807Apr 1 2003 — edited Apr 3 2003I have created a very basic applet which reads from a text file on my own hard drive containing Names and Web Addresses, creates buttons from these lines, panels from these buttons and puts them onto the screen.
This works in "appletviewer" but when I use it in IE5.5, I get a "red cross" and the "applet notinited" message. When I look at java console it says, file access denied.
I have tried a million different combinations of policy.txt, java.policy (both content and place) and Explorer "Security" java settings, but still get the same problem.
PLEASE HELP IF YOU CAN !!!!
Below is the source and a line from the text file :-
Source
------
import java.awt.*;
import java.awt.event.*;
import java.rmi.*;
import java.util.*;
import java.io.*;
import java.net.*;
import javax.swing.*;
public class JeffFavourites extends JApplet {
public void init() {
getContentPane().setLayout(new FlowLayout());
Vector url = new Vector();
Vector label = new Vector();
try {
File name = new File("JeffFavourites.txt");
FileReader file = new FileReader(name);
BufferedReader favList = new BufferedReader(file);
boolean eof = false;
boolean firstPane = true;
while (!eof) {
String favourite = favList.readLine();
if (favourite == null)
eof = true;
else {
if (favourite.equalsIgnoreCase("Pane"))
if (!firstPane) {
getContentPane().add(new ButtonPanel(label, url));
label.clear();
url.clear();
continue;
}
else {
firstPane = false;
continue;
}
else {
int i = favourite.indexOf("#");
label.add(favourite.substring(0, i));
url.add(favourite.substring(i + 1, favourite.length()));
}
}
}
} catch (IOException e) {
//
}
getContentPane().add(new ButtonPanel(label, url));
}
public void actionPerformed(ActionEvent evt) {
jmWebButton clicked = (jmWebButton)evt.getSource();
try {
URL load = new URL(clicked.url);
getAppletContext().showDocument(load);
} catch (MalformedURLException mue) {
showStatus("Bad URL: " + clicked.url);
}
}
}
class ButtonPanel extends JPanel {
ButtonPanel(Vector inLabel, Vector inUrl) {
super();
setLayout(new GridLayout(10, 1));
for (int i = 0; i < inLabel.size(); i++) {
add(new jmWebButton((String)inLabel.get(i), (String)inUrl.get(i)));
}
}
}
class jmWebButton extends JButton {
String url;
jmWebButton(String inLabel, String inUrl) {
super(inLabel);
url = inUrl;
}
}
Text File
---------
Pane
Barclays#http://www.barclays.co.uk