Results 1 to 4 of 4
Thread: reading dir in java applets
- 02-06-2008, 01:01 AM #1
Senior Member
- Join Date
- Dec 2007
- Location
- Spain
- Posts
- 578
- Rep Power
- 6
reading dir in java applets
Hello there,
I can´t make this the following methode to work inside a applet it wont give me the dir. and not even one of the panes.
please give me a hint
Willemjav
private 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
Imagearray = new Image[files.length];
for (int i = 0; i < files.length; i++) {
String str = files[i];
Imagearray[i] = downloadImage(str); // stores each image in a array for display
}
}
}
- 02-06-2008, 01:26 AM #2
- 02-06-2008, 11:58 PM #3
Senior Member
- Join Date
- Dec 2007
- Location
- Spain
- Posts
- 578
- Rep Power
- 6
dear hardwired
I did read some articles about security and I am aware of that issue concerning applets. Thanks for sending me that link anyway. I wrote a small slide show application for use on my web-site. Photos are present in a file folder called Imagestore and the applet should look for them on the server and download the content of the folder into the applet (I AM NOT TRYING TO ENTER A CLIENT ENVIRONMENT). The method (see bottom) reads simply the file directory of the file Imagestore and stores it into an array, which I copy into an image array for display. The application version works perfect but not the applet. The problem is the following method (when left out, the applet works okay). I do not understand which security issue is involved here. The panes should give me some feedback but they don´t.... the applet refuses to popup and I do not know way?
willem
private 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
Imagearray = new Image[files.length];
for (int i = 0; i < files.length; i++) {
String str = files[i];
Imagearray[i] = downloadImage(str); // stores each image in a array for display
}
}
}
and for display
public void paintComponent(Graphics g) {
if (Imagearray != null) {
count++;
if (count==Imagearray.length)
count = 0;
g.drawImage(Imagearray[count],0,0,getWidth(), getHeight(), this);
}
else
g.drawImage(testimage,0,0,getWidth(), getHeight(), this);
}
- 02-07-2008, 12:36 AM #4
Applets are much happier using a URL than a File for loading images. For more about this try the tutorial page How to Use Icons with special attention to the section Loading Images Using getResource and possibly Loading Images Into Applets.
Similar Threads
-
reading URL using java through proxy server
By asheesh in forum NetworkingReplies: 16Last Post: 04-25-2010, 02:15 PM -
Does OS intervene when reading Java text files
By Tina G in forum Advanced JavaReplies: 1Last Post: 04-07-2008, 02:29 PM -
using java applets for dag & drop interface
By frea in forum New To JavaReplies: 0Last Post: 03-27-2008, 08:31 PM -
reading textfile from java problem
By saytri in forum New To JavaReplies: 1Last Post: 01-17-2008, 02:13 AM -
Question abt.reading xml file using java
By gvi in forum Advanced JavaReplies: 6Last Post: 11-08-2007, 05:48 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks