best java friends
This small application lists the file content of the file imagestore of the work dir.
Those anybody know why the application works and the applet not (reading file directories from server comp should not involve a security problem, I believe). Is there a way to get around this problem?
All of the file dir. test program you´ll find here (the application version). Change the main into an innit and the thing does not work any more. Of course one should create a file folder called imagestore with some file content.

willemjav

package testimage;



import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.URL;
import java.applet.AudioClip;
import java.io.*;




public class Imagean extends JPanel implements ActionListener{

public static Image Images, testimage;
public static final String FILE_NAME="imagestore"; // the in the work dir
public String imageName;
File directory; // File object referring to the directory.
String[] files; // Array of file names in the directory.

JOptionPane infoPane;
JTextArea textArea;
JScrollPane scrollPane;
JButton testb;
JPanel Jp;


public Imagean() { // construtor
// reads the list of images files from Imagestore
infoPane = new JOptionPane("info");
textArea = new JTextArea(30,10);
testb = new JButton("test");
Jp = new JPanel();

textArea.setLineWrap(true);
textArea.setPreferredSize(new Dimension(250, 100));
JScrollPane scroller = new JScrollPane(textArea);
scroller.setPreferredSize(new Dimension(250,110));

add(scroller);
Jp.add(testb);
add(Jp);
textArea.setEditable(true);
String str = "testttt";
textArea.setText(str);
testb.addActionListener(this);
}

public void actionPerformed(ActionEvent evt) { // listen to button
readImageFilelist(FILE_NAME);

}


public void readImageFilelist(String dirname) { // gets the list of images
directory = new File(dirname);
if (directory.isDirectory() == false) {
if (directory.exists() == false)
JOptionPane.showMessageDialog(infoPane," there is no directory called " + directory);
else
JOptionPane.showMessageDialog(infoPane, directory + " is not a directory.");
}
else {
//JOptionPane.showMessageDialog(infoPane, directory + " it works");
files = directory.list(); // stores the list of file names


textArea.setText("Files in directory " + directory + ":\n");


for (int i = 0; i < files.length; i++)
textArea.append(" " + files[i] + "\n");


}

}
}





package testimage;



import javax.swing.JFrame;


public class Main {

public static void main(String[] args) {
JFrame window = new JFrame("Test");
Imagean content = new Imagean();
window.setContentPane(content);
window.setSize(400,400);
window.setLocation(100,100);
window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
window.setVisible(true);
}

}




import java.awt.*;
import java.awt.event.*;
import java.net.URL;
import javax.swing.*;

public class Imageanimation extends JApplet {

public void init() {
setContentPane( new Imagean() );
}

}