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-07-2008, 11:27 PM
Member
 
Join Date: Dec 2007
Posts: 81
willemjav is on a distinguished road
files and applets, please help
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() );
}

}
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
applets on mac what´s going on? willemjav Java Applets 6 04-19-2008 08:03 PM
Text and image files within jar files erhart Advanced Java 8 01-19-2008 05:43 AM
Applets writing to files bugger New To Java 2 11-20-2007 09:45 AM
how to convert mpeg files to .wav files christina New To Java 1 08-06-2007 05:14 AM
Applets and dll peiceonly Java Applets 1 04-01-2007 11:16 AM


All times are GMT +3. The time now is 01:22 PM.


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