Using jFileChooser and FileFilter

I am using a jFileChooser and want to add a file filter to only show .jpg files. I tried using...
FileFilter filter = new FileFilter();
filter.addExtension("jpg");
filter.setDescription("JPG Images");
fileChooser.setFileFilter(filter);
fileChooser.showSaveDialog(jPanel1)I get an error saying FileFilter is an abstract. I was wondering how I can successfully filter a jFileChooser. Also, what imports libraries do I need to perform the task. I have looked at sample code and it seems they do their own classes, I want to know how to handle this task using the libraries java provides.

Here's another way to do it, using an anon. inner
class:
JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(new FileFilter() {
public String getDescription() { return "Image
files"; }
public boolean accept(File f) {
if(f.isDirectory()) return true;
if(f.getName().endsWith(".jpg")) return true;
if(f.getName().endsWith(".png")) return true;
return false;
/code]
I find myself using a lot of anon. inner classes in
Swing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • File size using JFileChooser

    Hi,
    I have a File[] array (with directories and files on it), and want to take to another array the size of files only. I don't want to use File.length, because in this way i take the size of directories too.
    I tried to use this:
    for(int i=0; i<array.length; i++)
    File f = new File(path, array.toString());
    Size[i]=f.length();
    }//for
    but i don't think is good to have a Size array with "zeros" (when it finds directories) and long values (when it finds files).
    What do you propose me to do?
    Would it be good to use JFileChooser and how?
    Thanks,
    TSolonel

    What do you want to do with that array? Why not having a File[] array, so you have both length and isDirectory info. Sorting? Something else? JFileChooser seems irrelevant. But again, it's all up to what you are trying to do. Clarify

  • File Extention when using JFileChooser

    I'm using the JFileChooser and a FileFilter with for extensions of .ses, and I can't get it to append .ses to a file name if the user doesn't do it at the time they are in the File choser.
    What I've tried:
    JFileChooser fc = new JFileChooser();
    fc.setFileFilter(new SessionFileFilter());
    int retVal = fc.showSaveDialog(null);
    if(retVal == JFileChooser.APPROVE_OPTION){
         f = fc.getSelectedFile();
    if(!f.getName().endsWith(".ses")){
                   f=new File(f.getName()+".ses");
    ...SessionFileChooser...
    public boolean accept(File f) {
              boolean retval = false;
              int pos = f.getName().indexOf(".");
              if(pos != -1){
                   if(f.getName().substring(pos).equals(".ses")){
                        retval = true;
              return retval;
         public String getDescription() {
              return ".ses";
    ...any help would be appreciated, if you need source that compiles i'll get some worked out...
    to clarify the problem, if you go to save this web page and a dialog appears, you don't have to type .htm, but it automatically adds it before saving, this is what i'm trying to achieve.

    These two classes should do it. Let me know if there are any problems
    You are welcome to use and modify this code, but please don't change the package or take credit for it as your own work
    FileExtensionFilter
    ===============
    package tjacobs.ui.fc;
    import java.io.File;
    import javax.swing.filechooser.FileFilter;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Iterator;
    import java.util.List;
    public class FileExtensionFilter extends FileFilter {
        private ArrayList<String> mExtensionList;
        private String mDesc;
        public FileExtensionFilter (String extension) {
            mExtensionList = new ArrayList<String>(1);
            mExtensionList.add(extension);
        public FileExtensionFilter(List<String> extensions) {
            mExtensionList = new ArrayList();
              mExtensionList.addAll(extensions);
        public FileExtensionFilter(String[] extensions) {
            mExtensionList = new ArrayList();
            for (int i =0; i < extensions.length; i++) {
                mExtensionList.add(extensions);
         public void addExtension(String extension) {
              mExtensionList.add(extension);
         public Iterator<String> getExtensions() {
              Iterator<String> i = Collections.unmodifiableList(mExtensionList).iterator();
              return i;
    public boolean accept(File file) {
         if (file.isDirectory()) {
              return true;
    String name = file.getName();
    int idx = name.indexOf(".");
    String type = "";
    if (idx != -1) {
    type = name.substring(idx + 1);
    type = type.toLowerCase();
    return mExtensionList.contains(type);
    public void setDescription(String desc) {
    mDesc = desc;
    public String getDescription() {
    if (mDesc == null) {
    mDesc = "";
    for (int i = 0; i < mExtensionList.size(); i++) {
    mDesc += (i != 0 ? ", " : "") + "." + mExtensionList.get(0).toString();
    mDesc+= " files";
    return mDesc;
    public String getType () {
    return mExtensionList.get(0).toString();
    public static class HTMLFilter extends FileExtensionFilter {
    public HTMLFilter () {
    super(new String[] {"html", "htm"});
    setDescription("Web Page Files");
    public static class RTFFilter extends FileExtensionFilter {
    public RTFFilter () {
    super("rtf");
    setDescription("Rich Text Format Files");
    public static class TextFilter extends FileExtensionFilter {
    public static final String TYPES[] = new String[] {"txt", "text", "java"};
         public TextFilter () {
    super(TYPES);
    setDescription("Text Files");
    FileChooser
    ==========
    * Created on Jun 22, 2005 by @author Tom Jacobs
    package tjacobs.ui.fc;
    import java.awt.Component;
    import java.io.File;
    import java.util.List;
    import javax.swing.JFileChooser;
    import javax.swing.filechooser.FileFilter;
    import javax.swing.filechooser.FileSystemView;
    public class FileChooser extends JFileChooser {
         public FileChooser(FileExtensionFilter filter) {
              super();
              addChoosableFileFilter(filter);
         public FileChooser(String type) {
              this (new FileExtensionFilter(type));
         public FileChooser(List<String> types) {
              this (new FileExtensionFilter(types));
         public FileChooser(String path, FileExtensionFilter filter) {
              super(path);
              addChoosableFileFilter(filter);
              // TODO Auto-generated constructor stub
         public FileChooser(String path, String type) {
              this(path, new FileExtensionFilter(type));
              // TODO Auto-generated constructor stub
         public FileChooser(String path, List<String> types) {
              this(path, new FileExtensionFilter(types));
              // TODO Auto-generated constructor stub
         public FileChooser(File path, FileExtensionFilter filter) {
              super(path);
              addChoosableFileFilter(filter);
         public FileChooser(File path, String type) {
              this(path, new FileExtensionFilter(type));
              // TODO Auto-generated constructor stub
         public FileChooser(File path, List<String> types) {
              this(path, new FileExtensionFilter(types));
              // TODO Auto-generated constructor stub
         public FileChooser(FileSystemView arg0, FileExtensionFilter filter) {
              super(arg0);
              addChoosableFileFilter(filter);
         public FileChooser(FileSystemView arg0, String type) {
              this(arg0, new FileExtensionFilter(type));
              // TODO Auto-generated constructor stub
         public FileChooser(FileSystemView arg0, List<String> types) {
              this(arg0, new FileExtensionFilter(types));
              // TODO Auto-generated constructor stub
         public FileChooser(File path, FileSystemView arg1, FileExtensionFilter filter) {
              super(path, arg1);
              addChoosableFileFilter(filter);
         public FileChooser(File path, FileSystemView arg1, String type) {
              this(path, arg1, new FileExtensionFilter(type));
                        // TODO Auto-generated constructor stub
         public FileChooser(File path, FileSystemView arg1, List<String> types) {
              this(path, arg1, new FileExtensionFilter(types));
              // TODO Auto-generated constructor stub
         public FileChooser(String path, FileSystemView arg1, FileExtensionFilter filter) {
              super(path, arg1);
              addChoosableFileFilter(filter);
              // TODO Auto-generated constructor stub
         public FileChooser(String path, FileSystemView arg1, String type) {
              this(path, arg1, new FileExtensionFilter(type));
              // TODO Auto-generated constructor stub
         public FileChooser(String path, FileSystemView arg1, List<String> types) {
              this(path, arg1, new FileExtensionFilter(types));
              // TODO Auto-generated constructor stub
         public int showSaveDialog(Component c) {
              int ok = super.showSaveDialog(c);
              if (ok == JFileChooser.APPROVE_OPTION) {
                   FileFilter filter = getFileFilter();
                   if (filter instanceof FileExtensionFilter) {
                        File f = getSelectedFile();
                        if (!filter.accept(f)) {
                             setSelectedFile(new File(f.getAbsolutePath() + "." + ((FileExtensionFilter)filter).getType()));
              return ok;

  • Get the file directory/location using JFileChooser

    Dear,
    How to get the file directory and it location with using JFilechooser after select the indicate file?
    Thanks

    There is an example at the top of JFileChooser's doc.
    http://java.sun.com/j2se/1.4.1/docs/api/javax/swing/JFileChooser.html

  • Folders that having non-ascii chars are not displaying on MAC using JFileChooser

    On MAC OS X 10.8.2, I have latest Java 1.7.25 installed. When I run my simple java program which allows me to browse the files and folders of my native file system using JFileChooser, It does not show the folders that having non-ascii char in there name. According this link, this bug had been reported for Java 7 update 6. It was fixed in 7 Update 10. But I am getting this issue in Java 1.7.21 and Java 1.7.25.
    Sample Code-
    {code}
    public class Encoding {
    public static void main(String[] arg) {
    try {
    //NOTE : Here at desktop there is a folder DKF}æßj having spacial char in its name. That is not showing in file chooser as well as while is trying to read for FILE type, it is not identify by Dir as well as File - getting File Not Found Exception
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (IllegalAccessException ex) {
    Logger.getLogger(Encoding.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnsupportedLookAndFeelException ex) {
    Logger.getLogger(Encoding.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ClassNotFoundException ex) {
    Logger.getLogger(Encoding.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
    Logger.getLogger(Encoding.class.getName()).log(Level.SEVERE, null, ex);
    JFileChooser chooser = new JFileChooser(".");
    chooser.showOpenDialog(null);
    {code}

    Hi,
    Did you try this link - osx - File.list() retrieves file names with NON-ASCII characters incorrectly on Mac OS X when using Java 7 from Oracle -…
    set the LANG environment variable. It's a GUI application that I want to deploy as an Mac OS X application, and doing so, the LSEnvironment setting
    <key>LSEnvironment</key> <dict> <key>LANG</key> <string>en_US.UTF-8</string> </dict>

  • JFileChooser and the filename

    Hi All,
    I'm going for 11 new things learned today about Java!
    I'm using JFileChooser to prompt for a file, and I need to capture the filename and see if it's inside the file.
    I'm getting a "found int, expected boolean" compile error. Can comeone enlighten?
    Thanks!
    MVP
    String strFileName;
    JFileChooser jfc = new JFileChooser();
    strFileName = jfc.getSelectedFile().getName();  // tried both these
    strFileName = jfc.getName(); // lines
    currentLine = strInFileArray;
    if(currentLine.indexOf(strFileName)) //compile error on this line

    I didn't say it didn't compile, it does compile.
    And I know it doesn't do anything because I display
    currentLine before and after the change is attempted.
    And I did read up on the method - how do you think I
    found it in the first place?If you did, then what does it say after the word "Returns" in the method description? And where else could you have found the method? Some IDEs will spit out a list of possible methods that can be called from an option. One of the reaosns why I suggest new comers shouldn't use IDEs to start (forces them to learn about the API which is the best possible thing for someone in your (ie newbie, nothing personal) possition to do).
    >
    Now, if statements like
    i++
    setBackground(Color.WHITE)
    setFont(myfont)
    getContentPane().setLayout()
    repaint()
    and others (iow, no '=' for assignment)
    all change objects or attributes of objects, it seems
    a logical assumption to me that
    currentLine.replaceAll(strFileName,NEW_FILE_NAME);
    will change the object 'currentLine'.So you assume that all methods work the sae way, and forget the docs? The first sentance of the second paragraph in the String API says:
    "Strings are constant; their values cannot be changed after they are created. "
    So you see, the answer to your question, and the why it is the way it is, are both in the API.
    >
    Finally, (not for you jverd, you are polite), to be
    called names by supposedly mature posters on this
    forum - which exists specifically for beginner-level
    questions like mine - is just amazing. Excuse me for
    thinking I might find help and assistance instead of
    abuse.A double standard, yes? I have to be mature, but not you? You whine alot. You can ask questions without whining, others do it all the time (you didn't whine in the first question in this thread, and I tried to answer (well, tried to get you to answer yourself, which I believe is more beneficial)). Once you started your whining again, I became immature also. No apologies here.
    And even if the assinine (which it was intentionally) it still had some help (by pointing to the API). You saw the API before (which is good) but I did not know that, and your questions seemed to indicate otherwise.
    >
    TheReallyDisappointedMVPBuck up. Nothing personal. Just ask questions differently, that's all.

  • Using JFileChooser in GUI Builder / Matisse

    Would appreciate any help with how to modify the code created by the NetBeans GUI Builder / Matisse to use jFileChooser.
    I've added a Menu item to act as a file Open option, called OpenItem, and the GUI builder has added a listener which points to a method OpenItemActionPerformed:
    private void OpenItemActionPerformed(java.awt.event.ActionEvent evt) {                                        
            // TODO add your handling code here:
    } I have also added a jFileChooser component, named jFileChooser1, but if I try to use it in the OpenItemActionPerformed method I get an error.
    private void OpenItemActionPerformed(java.awt.event.ActionEvent evt) {                                        
           JFileChooser1.  
    }     shows error: "<identifier> expected" (as soon as I get to the dot).
    The variable seems to be defined:
    private void initComponents() {
            jFileChooser1 = new javax.swing.JFileChooser();
    }// Variables declaration - do not modify
    private javax.swing.JFileChooser jFileChooser1;
    // End of variables declaration
    Maybe I have gone about this the wrong way, so any clues as to either how I can get the jFileChooser1 variable to work or any way I can use JFilechooser with GUI Builder created application would be much appreciated.
    Thanx in advance.

    The following example creates a file chooser and displays it as first an open-file dialog and then as a save-file dialog:
        String filename = File.separator+"tmp";
        JFileChooser fc = new JFileChooser(new File(filename));
        // Show open dialog; this method does not return until the dialog is closed
        fc.showOpenDialog(frame);
        File selFile = fc.getSelectedFile();
        // Show save dialog; this method does not return until the dialog is closed
        fc.showSaveDialog(frame);
        selFile = fc.getSelectedFile();Here is a more elaborate example that creates two buttons that create and show file chooser dialogs.
        // This action creates and shows a modal open-file dialog.
        public class OpenFileAction extends AbstractAction {
            JFrame frame;
            JFileChooser chooser;
            OpenFileAction(JFrame frame, JFileChooser chooser) {
                super("Open...");
                this.chooser = chooser;
                this.frame = frame;
            public void actionPerformed(ActionEvent evt) {
                // Show dialog; this method does not return until dialog is closed
                chooser.showOpenDialog(frame);
                // Get the selected file
                File file = chooser.getSelectedFile();
        // This action creates and shows a modal save-file dialog.
        public class SaveFileAction extends AbstractAction {
            JFileChooser chooser;
            JFrame frame;
            SaveFileAction(JFrame frame, JFileChooser chooser) {
                super("Save As...");
                this.chooser = chooser;
                this.frame = frame;
            public void actionPerformed(ActionEvent evt) {
                // Show dialog; this method does not return until dialog is closed
                chooser.showSaveDialog(frame);
                // Get the selected file
                File file = chooser.getSelectedFile();
        };Here's some code that demonstrates the use of the actions:
        JFrame frame = new JFrame();
        // Create a file chooser
        String filename = File.separator+"tmp";
        JFileChooser fc = new JFileChooser(new File(filename));
        // Create the actions
        Action openAction = new OpenFileAction(frame, fc);
        Action saveAction = new SaveFileAction(frame, fc);
        // Create buttons for the actions
        JButton openButton = new JButton(openAction);
        JButton saveButton = new JButton(saveAction);
        // Add the buttons to the frame and show the frame
        frame.getContentPane().add(openButton, BorderLayout.NORTH);
        frame.getContentPane().add(saveButton, BorderLayout.SOUTH);
        frame.pack();
        frame.setVisible(true);

  • Problem using JFileChooser to select a destination directory

    If you set JFileChooser to DIRECTORIES_ONLY, a user has to single click on the desired directory and click on the approveButton. This works just fine - you get the user's desired directory using getSelectedFile().
    e.g. /home/joeuser/docs
    But if the user double-clicks on their desired directory (a common user practice), the directory is opened AND the directory name is stuck in the File Name: field. If they now click on the approveButton, the returned selected directory is the user's desired directory PLUS the name of the directory again. Not what the user intended.
    e.g. /home/joeuser/docs/docs
    Now, when you keep the File Name: field from being filled in when the user double-clicks on a directory, you have encounter another problem. The approveButton will not activate unless there is something in the File Name: field!
    Does anybody have a solution for the approveButton working with an empty File Name: field?
    Thanks,
    Scott

    I had the same problem. Gave up with JFileChooser and made a directory chooser that only display the diectory structure in a JTree and no file stuff at all.
    Source: http://www.msticky.freeserve.co.uk/JDialog_directoryChooser.java
    to use it; String selectedDirPath=JDialog_directoryChooser.choose(stringTitle, stringInitialSelectedPath)
    returns the selected directory path or null if none selected.
    To make it work alone you'll need to remove my RRException class. If you want to see it in use first download noname.jar from http://www.msticky.freeserve.co.uk
    ps. my site needs testing
    thanks, sticky

  • JFileChooser and security

    Has anybody got the JFileChooser to open the user.dir or user.home directory? [I have used JFileChooser(".")] I have used the policytool to generate a policy file and also have tried to follow Irene's 10 steps to signing an applet but non have worked. I keep getting the security exception thrown that access denied to user.home or user.dir. Does anybody have an example policy file and a snippet of the JFileChooser code they used to open the local file system without getting a security exception throw? Any help would be much appreciated!
    Thank you in advance,
    dave

    The Notpad demo uses the JNLP api to read and write files. The api doc can be found at:
    http://java.sun.com/products/javawebstart/docs/javadoc/index.html
    Although the Notpad demo source is not available, there is other sample code available at:
    http://developer.java.sun.com/developer/releases/javawebstart/
    Included here is the webpad demo, which uses the FileOpenService and
    FileSaveService API's.

  • JFileChooser and FileFilters

    I have the following problem:;
    I have a JFileChooser and I attached a FileFilter to it, which only allows files with the extension *.in and *.inx. Everything works well - only files with these extensions are shown in the Dialog.
    But as a user I expect, that it is not a fault if I only type in the name of the file, because I expect the programme to add the extension automatically. For example in an OpenDialog, the user sees the file test.inx and the types in "test", because he/she thinks that the extension will be added.
    This is not the case...and which is even worse, the call of fileChooser.getSelectedFiles() will return an empty array. Hence there is no possibility for the programme to add the file extension.....
    How can solve this problem?? What is my mistake?? I cannot image that Swing is not able to do this, because this common FileDialog behaviour....
    I thank everybody who tries to help me...

    The quick and dirty workaround would be to create a "Save" dialog (setDialogType method), set the Button texts to whatever you want, the same for title. When the dialog returns, you can check the file (getSelectedFile()), and if it does not exist, try the same name with the extension(s).

  • Problem using JFileChooser

    Hi,
    I am encoutering a strange error dialog, javaw.exe No-Disk dialog box with this message "There is no disk in the drive. please insert a disk in drive A" when using JFileChooser.
    I have been referring to some forums and understood this is a bug. But most encountered this when they are using it with Java Web Service or some web application.
    I have Windows 2000 and mine is a java application. I have tried a workaround with WindowsAltFileSystemView but that does work with Windows 2000.
    So is there any workaround..help needed.
    thanks.

    If you do not do so already, try setting a starting point for your JFileChooser.
    JFileChooser chooser = new javax.swing.JFileChooser();
    chooser.setCurrentDirectory( someDirectory );The "someDirestory" could be any directory you want or need depending on Platform independance or not.
    regards,
    jarshe

  • Using JFileChooser to select directory only

    Hi. I am using JFileChooser to let the user to select the directory to save some files into the user-selected directory. I set the JFileChooser to show only directory and not files. Below show part of my code:
    private JFileChooser chooser = new JFileChooser();
    chooser.setFileHidingEnabled(true);
    chooser.setMultiSelectionEnabled(false);
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
         chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    int state = chooser.showDialog(frame, "Select Directory");
    if (state == JFileChooser.APPROVE_OPTION )
    file = chooser.getCurrentDirectory();
    However, the File reference that i get is not the user-selected directory. Please help.
    Thank you.

    Hi,
    i found that if user writes in the text field of save dialog name of the file(but application needs directory), getCurrentDirectory() returns correct directory. but if user chooses directory, getCurrentDirectory() returns parent directory but getSelectedFile() returns correct one, so i suggest something like this(it's nasty but it works [i hope;])
    JFileChooser dirChooser = new JFileChooser("");
    dirChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    if (dirChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION)
    java.io.File curDir = dirChooser.getSelectedFile().isDirectory()?dirChooser.getSelectedFile():dirChooser.getCurrentDirectory();

  • RMI -How to use JFileChooser to see remote computer FileSystem

    i hav made a program in RMI which uses JFileChooser to show remote-machine File System. i have made my own FileSyatemView class (MyFileSyatemViewClient which extends FileSystemView) and override all the methods of FileSystemView Except getFileSystemView.
    Similarly i have made my own FileView(MyFileViewClient).
    i fed these to the JFileChooser. And object of JFileChooser i am recieving from the server through remote method getFileChooser(). Thus the code is like:
                             MyFileSystemViewClient mfsvc; //Defined Globally
                             MyFileViewClient mfvc; //Defined Globally
    public void actionPerformed(ActionEvent ae)
    if(ae.getActionCommand().equals("Open"))
                             mfsvc = new MyFileSystemViewClient();
                             mfvc = new MyFileViewClient();
    try
    JFileChooser jfc=fi.getFileChooser();
    // "fi" is the FileInterface through which we access server-side methods.
                                  jfc.setFileSystemView(mfsvc);
                                  jfc.setFileView(mfvc);                              
                                  int retval = jfc.showOpenDialog(null);
                                  if(retval==JFileChooser.APPROVE_OPTION)
                                       getf = jfc.getSelectedFile();
                             catch(Exception e)
                                  System.out.println("Error Occurred In OPEN :"+e);
    MyFileSystemViewClient class looks as :
    public class MyFileSystemViewClient extends FileSystemView
                   public MyFileSystemViewClient()
                        //super();
                        try{
                        fi.invokeMyFileSystemViewCons();
                        }catch(Exception e){
                             System.out.println("Error in invokeMyFileSystemViewCons : "+e);
                   public File[] getFiles(File file,boolean tr)
                        try{
                        return fi.getFiles(file,tr);
                        }catch(Exception e){
                             System.out.println("Error in getFiles : "+e);
                             return null;}
                   public File getHomeDirectory()
                        try{
                        return fi.getHomeDirectory();
                        }catch(Exception e){
                             System.out.println("Error in getHomeDirectory : "+e);
                             return null;}
                   public File getParentDirectory(File dir)
                        try{
                        return fi.getParentDirectory(dir);
                        }catch(Exception e){
                             System.out.println("Error in getParentDirectory : "+e);
                             return null;}
                   public File[] getRoots()
                        try{                         
                        return fi.getRoots();                    
                        }catch(Exception e){
                             System.out.println("Error in getRoots : "+e);
                             return null;}
                   public File getDefaultDirectory()
                        try{
                        return fi.getDefaultDirectory();
                        }catch(Exception e){
                             System.out.println("Error in getDefaultDirectory : "+e);
                             return null;}
                   public File createNewFolder(File containingDir)
                        try{
                        return fi.createNewFolder(containingDir);
                        }catch(Exception e){
                             System.out.println("Error in createNewFolder : "+e);
                             return null;}
                   public String getSystemDisplayName(File f)
                        try{
                        return fi.getSystemDisplayName(f);
                        }catch(Exception e){
                             System.out.println("Error in getSystemDisplayName : "+e);
                             return null;}
                   public String getSystemTypeDescription(File f)
                        try{
                        return fi.getSystemTypeDescription(f);
                        }catch(Exception e){
                             System.out.println("Error in getSystemTypeDescription : "+e);
                             return null;}
                   public File getChild(File parent, String fileName)
                        try{
                        System.out.println("Child FIle : "+fi.getChild(parent,fileName));
                        return fi.getChild(parent,fileName);
                        }catch(Exception e){
                             System.out.println("Error in getChild : "+e);
                             return null;}
                   public boolean isParent(File folder,File file)
                        try
                             return fi.isParent(folder,file);
                        catch(Exception e)
                        System.out.println("Error in isParent : "+e);
                             return false;     
                   public Icon getSystemIcon(File f)
                        try{
                        return fi.getSystemIcon(f);
                        catch(Exception e)
                        System.out.println("Error in getSystemIcon : "+e);
                             return null;     
                   public boolean isDrive(File dir)
                        try{
                        return fi.isDrive(dir);
                        catch(Exception e)
                        System.out.println("Error in isDrive : "+e);
                             return false;     
                   public boolean isFileSystem(File f)
                        try{
                        return fi.isFileSystem(f);
                        catch(Exception e)
                        System.out.println("Error in isFileSystem : "+e);
                             return false;     
                   public boolean isFileSystemRoot(File dir)
                        try{
                        return fi.isFileSystemRoot(dir);
                        catch(Exception e)
                        System.out.println("Error in isFileSystemRoot : "+e);
                             return false;     
                   public boolean isFloppyDrive(File dir)
                        try{
                        return fi.isFloppyDrive(dir);
                        catch(Exception e)
                        System.out.println("Error in isFloppyDrive : "+e);
                             return false;     
                   public boolean isRoot(File f)
                        try{
                        return fi.isRoot(f);
                        catch(Exception e)
                        System.out.println("Error in isRoot : "+e);
                             return false;     
                   public Boolean isTraversable(File f)
                        try{
                        return fi.isTraversable(f);
                        catch(Exception e)
                        System.out.println("Error in isTraversable : "+e);
                             return null;     
    //.....................................................End of the MyFileSystemViewClient.......................
    Thus each method in the class MyFileViewClient brings the required information from the server. BUT we are getting two problems:
    1) so many folders at the server-side are shown as files in the dialogbox.
    2)dialog box shows all "folders of the desktop" of the local filesystem and some more "local drives without any name". when i click a folder in the dialog box which is on my local machine, nothing happens. they are just the icon with the name but don't show the content. although i can easily see the drives of the remote filesystem and browse through except for the problem stated above at no.1.
    ok guys now its your turn to speak up.....
    plz give some suggestions and comments..
    ciao!!

    sry to all friends there who can't read the code clearly. as per the suggestion i am putting the code afresh..
    the main client class which binds to the server contains following piece of code :
    MyFileSystemViewClient mfsvc; //Defined Globally
    MyFileViewClient mfvc; //Defined Globally
    public void actionPerformed(ActionEvent ae)
         if(ae.getActionCommand().equals("Open"))
              mfsvc = new MyFileSystemViewClient();
              mfvc = new MyFileViewClient();
              try
                   JFileChooser jfc=fi.getFileChooser();//Requesting JFileChooser object from server.
                   // "fi" is the FileInterface through which we access server-side methods.
                   jfc.setFileSystemView(mfsvc);
                   jfc.setFileView(mfvc);
                   int retval = jfc.showOpenDialog(null);
                   if(retval==JFileChooser.APPROVE_OPTION)
                   getf = jfc.getSelectedFile();
              catch(Exception e)
              System.out.println("Error Occurred In OPEN :"+e);
    }i again like to convey that, "fi" is the FileInterface through which we access server-side methods.
    MyFileSystemViewClient class looks as :
    public class MyFileSystemViewClient extends FileSystemView
                   public MyFileSystemViewClient()
                        //super();
                        try{
                        fi.invokeMyFileSystemViewCons();
                        }catch(Exception e){
                             System.out.println("Error in invokeMyFileSystemViewCons : "+e);
                   public File[] getFiles(File file,boolean tr)
                        try{
                        return fi.getFiles(file,tr);
                        }catch(Exception e){
                             System.out.println("Error in getFiles : "+e);
                             return null;}
                   public File getHomeDirectory()
                        try{
                        return fi.getHomeDirectory();
                        }catch(Exception e){
                             System.out.println("Error in getHomeDirectory : "+e);
                             return null;}
                   public File getParentDirectory(File dir)
                        try{
                        return fi.getParentDirectory(dir);
                        }catch(Exception e){
                             System.out.println("Error in getParentDirectory : "+e);
                             return null;}
                   public File[] getRoots()
                        try{                         
                        return fi.getRoots();                    
                        }catch(Exception e){
                             System.out.println("Error in getRoots : "+e);
                             return null;}
                   public File getDefaultDirectory()
                        try{
                        return fi.getDefaultDirectory();
                        }catch(Exception e){
                             System.out.println("Error in getDefaultDirectory : "+e);
                             return null;}
                   public File createNewFolder(File containingDir)
                        try{
                        return fi.createNewFolder(containingDir);
                        }catch(Exception e){
                             System.out.println("Error in createNewFolder : "+e);
                             return null;}
                   public String getSystemDisplayName(File f)
                        try{
                        return fi.getSystemDisplayName(f);
                        }catch(Exception e){
                             System.out.println("Error in getSystemDisplayName : "+e);
                             return null;}
                   public String getSystemTypeDescription(File f)
                        try{
                        return fi.getSystemTypeDescription(f);
                        }catch(Exception e){
                             System.out.println("Error in getSystemTypeDescription : "+e);
                             return null;}
                   public File getChild(File parent, String fileName)
                        try{
                        System.out.println("Child FIle : "+fi.getChild(parent,fileName));
                        return fi.getChild(parent,fileName);
                        }catch(Exception e){
                             System.out.println("Error in getChild : "+e);
                             return null;}
                   public boolean isParent(File folder,File file)
                        try
                             return fi.isParent(folder,file);
                        catch(Exception e)
                        System.out.println("Error in isParent : "+e);
                             return false;     
                   public Icon getSystemIcon(File f)
                        try{
                        return fi.getSystemIcon(f);
                        catch(Exception e)
                        System.out.println("Error in getSystemIcon : "+e);
                             return null;     
                   public boolean isDrive(File dir)
                        try{
                        return fi.isDrive(dir);
                        catch(Exception e)
                        System.out.println("Error in isDrive : "+e);
                             return false;     
                   public boolean isFileSystem(File f)
                        try{
                        return fi.isFileSystem(f);
                        catch(Exception e)
                        System.out.println("Error in isFileSystem : "+e);
                             return false;     
                   public boolean isFileSystemRoot(File dir)
                        try{
                        return fi.isFileSystemRoot(dir);
                        catch(Exception e)
                        System.out.println("Error in isFileSystemRoot : "+e);
                             return false;     
                   public boolean isFloppyDrive(File dir)
                        try{
                        return fi.isFloppyDrive(dir);
                        catch(Exception e)
                        System.out.println("Error in isFloppyDrive : "+e);
                             return false;     
                   public boolean isRoot(File f)
                        try{
                        return fi.isRoot(f);
                        catch(Exception e)
                        System.out.println("Error in isRoot : "+e);
                             return false;     
                   public Boolean isTraversable(File f)
                        try{
                        return fi.isTraversable(f);
                        catch(Exception e)
                        System.out.println("Error in isTraversable : "+e);
                             return null;     
    //--------------------------------------------------------------------

  • Using jfilechooser

    hi all,
    how to use jfilechooser to select a file available in another computer of my LAN.
    i used setFileSelectionMode(JFileChooser.FILES_ONLY);with this statement, if i give 'c:' or any local/mapped drive names in text box, it lists the files properly and i can choose the file.
    but, if i give the IP address of another system, i.e like '\\192.168.0.243', it simply accepts this (\\192.168.0.243) as filename and closes the file chooser dialog. if i type the ip address, the file chooser should list the shared drives in that system.  how to do this?
    i tried java.awt.filedialog, but it does this, but supports only single file selection
    thanking you.

    rnoack wrote:
    1) i don't find it amusing that we are even having this conversation, it is immature and i have tried to end it twice now but you always seem to want to have the last word (which would be fine with me if it didn't negatively reflect on my intentions or values)The "problem" in this case is that is that Darryl.Burke is correct. Cross-posting is really rude, it means that you don't care about the time that people spend answering questions. Most frequenst posters at all forums and mailing lists will tell you that.
    Cross-posting and not saying in the post that you are cross-posting is even worse. (Cross-posts are often removed from these forums).
    >
    2) i never did, and never will think that i can tell you want to do or not to do. i was merely offering advice which i feel and will continue to feel regardless of your beliefs is for the best of all related communities.Note that Darryl is a moderator and tried to tell you that you shouldn't cross-post. Most frequent posters would have done that if they had found out that you were cross-posting. The only mistake that Darryl did is that he thought that you were going to listen to his advice even if he didn't make that specific post as a moderator.
    Kaj
    Ps. I also blocked an abusive post.

  • JFILECHOOSER and ACCESSIBILITY

    I have an Open file dialog box which was coded using jFileChooser. It is very important that my open dialog i.e. jFileChooser can be used without using a mouse.
    Currently I cannot figure out which key will let me open folders to navigate the file structure.
    You can only navigate by double clicking on the folder.
    Does anyone know the keyboard shortcuts for using a JFileChooser or where I can look to find them?
    Or can the JfileChooser folders be navigated by a keyboard???

    To activate the combo - F4 + arrows
    To go up a level - tab to the 'up one level button'
    To access the files - tab and then use the arrow keys
    To enter a file open it with Alt + O
    These are the only ones I know of so I may be showing my ignorance here. However the opening of the button is exceptionally annoying cause focus shifts to the button and then you have to tab round again. ie The left and right arrow keys need fixing to allow for quick navigation

Maybe you are looking for

  • Doesn't Fill Up Screen - Help

    I just got my first Apple Computer (IMac) and am surprised to find out that the Text on the internet does not fill up the screen. I have asked the help desk how to make it bigger and they suggested command +. Unfortunately, that makes the words bigge

  • Technical problem in ms office 2013

    When ever I open the files, the corresponding one launches but the file does not open. Some times, even if the file opens (which is very rare), the file stops responding in a minute or when ever I click enable editing.  Error is Word is not respondin

  • Logical reads VS physical reads

    hello all, What is the difference between logical reads and physical read ??? I do get the part of logical read (from buffer) and physical read(from disk). And also do know physical reads are bad, but is it true in oracle world..logical reads are bad

  • Where is the missing documentation?

    Hi there, Does anyone know where is the missing documentation located for JDBC of Oracle 7.3.4? The correct url should be http://otn.oracle.com/docs/tech/java/sqlj_jdbc/htdocs/jdbc_doc.htm, but I couldnt see it. Thanks Neo

  • Alert button style

    Dear all When using Alert.show("Hey !", 'Alert', mx.controls.Alert.OK) The style is not the Style of the CS Application (in this case Illustrator) So I use var alertCSS:CSSStyleDeclaration = StyleManager.getStyleManager(null).getStyleDeclaration("mx.