Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-06-2008, 02:01 AM
Member
 
Join Date: Dec 2007
Posts: 78
willemjav is on a distinguished road
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
}

}

}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-06-2008, 02:26 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,015
hardwired is on a distinguished road
How Can An Applet Read Files On The Local File System
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 02-07-2008, 12:58 AM
Member
 
Join Date: Dec 2007
Posts: 78
willemjav is on a distinguished road
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);


}
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 02-07-2008, 01:36 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,015
hardwired is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
reading URL using java through proxy server asheesh Networking 11 06-28-2008 07:08 PM
Does OS intervene when reading Java text files Tina G Advanced Java 1 04-07-2008 03:29 PM
using java applets for dag & drop interface frea New To Java 0 03-27-2008 09:31 PM
reading textfile from java problem saytri New To Java 1 01-17-2008 03:13 AM
Question abt.reading xml file using java gvi Advanced Java 6 11-08-2007 06:48 PM


All times are GMT +3. The time now is 07:14 AM.


VBulletin, Copyright Đ2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright Đ2006 - 2007, www.java-forums.org