Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

Thanks so much for having a place for us propeller heads to hang out and chat.

Geography

Where in the world do Tek-Tips members come from?
puremm (TechnicalUser)
11 Sep 07 17:53
Hi - not sure if this is the right forum - but

Ive written a small applet ans singed it to select a few files and put them in a list . All initated by java script calls.
The trouble is as soon as the jfilechooser dialog is shown the applet freezes for up to 10 mins maybe more ?

I've downloaded the latest jdk and jre -- any help is gratefuly received. I get the same effect using IE7 and firefox

import java.net.*;
import java.io.*;
import java.awt.*;
import java.lang.String.*;
import java.beans.*;
import javax.swing.*;
import java.util.List;



public class PictDeskUploader extends JApplet //implements ActionListener
{
public static final long serialVersionUID = 1L;
private DefaultListModel listModel; // We need a model to adjust the list
public JList pictFileList; // the Jlist object that will hold the list of files
Container contentpane; // used to reference where the list will be placed
public JFileChooser fc; // file chooser
private File[] files; // Array to hold the file chooser results

public void init ()
{
//evt.start();
try {
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

fc = new JFileChooser();

contentpane = this.getContentPane();
contentpane.setLayout(new FlowLayout());
listModel = new DefaultListModel();
pictFileList = new JList(listModel);
pictFileList.setSelectedIndex(0);
pictFileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
contentpane.add(new JScrollPane(pictFileList));
}catch(Exception e){
e.printStackTrace();
}
}


public int addFiles()
{
int i; //array loop counter

String fname ;
fc.setMultiSelectionEnabled(true); // Allow for multiple selections
fc.showOpenDialog (this); // Show the file chooser dialog to the user
files=fc.getSelectedFiles(); // Load the file array with the current selected files
//evt.start();
for ( i = 0; i < files.length; i++) { //loop through the array of files and only add if we havent got it already
fname=files.getPath() ;
if (pictFileList.getModel().getSize() > 0 )
{
if ( pictFileList.getNextMatch(fname, 0, javax.swing.text.Position.Bias.Forward) == -1 )
listModel.addElement ( fname );
} else
listModel.addElement ( fname );
}
// File Add files
return 0;
}
public int deleteFiles()
{
int i; //array loop counter // File remove code
if (pictFileList.getModel().getSize() > 0 ){ // only if more than 1 file
for(i = 0; i < pictFileList.getModel().getSize(); i++) {
int index = pictFileList.getSelectedIndex();
listModel.remove(index);
}
}
return 0;
}

}
Diancecht (Programmer)
12 Sep 07 5:11
I'd try setting the initial path of JFileChooser to a known location. Otherwise, it may be slow accesing the filesystem as the Windows explorer is sometimes, specially if there are network drives.

Cheers,
Dian
AntiMindKiller (Programmer)
27 Sep 07 17:18
Most likely it is hanging because you are trying to access the file system through an applet, which isn't usually permitted.

This article has some information about signing you applet so that it can access the file system:

http://forum.java.sun.com/thread.jspa?threadID=440016&amp;messageID=1981556

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close