Results 1 to 6 of 6

Thread: Filechooser

  1. #1
    Joe2003 is offline Member
    Join Date
    Jan 2008
    Posts
    21
    Rep Power
    0

    Default Filechooser

    Hey

    Is it possible to open a filechooser that points at a paticular dirrectory?

    Say i have the dir:-

    /home/joe/Desktop/files

    I want the filechooser to show everything in this dir. Is it possible

    thanks alot

    Joe

  2. #2
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    Hello,

    Ya it is possible....where do you want it.
    In jsp or in applet...or else


    sanjeev

  3. #3
    Joe2003 is offline Member
    Join Date
    Jan 2008
    Posts
    21
    Rep Power
    0

    Default

    Its just a standard java program, so neither :s

    code is something like this:-

    Java Code:
    public static void main (String [] args)
        {
           
            JFileChooser fc = new JFileChooser();
            int returnVal = fc.showOpenDialog(this);
            System.out.println(returnVal);
            System.out.println(fc.getSelectedFile());
    
        }
    but I just wanna open the filechooser to point at a given dir

  4. #4
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    There is another JFileChooser constructor that needs a parameter, and that parameter is a file, should be a directory....

    If the received value from the parameter is a file, then the directory where that file is located will be used as a starting directory of JFileChooser....

    kind regards,
    sukatoa

  5. #5
    iyantea is offline Member
    Join Date
    Feb 2009
    Posts
    1
    Rep Power
    0

    Default

    how to use JFileChooser in jsp and applet ?
    On client pc must install jre/jse ?

    is there any other method to send file from client?

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    To run Java applet you need to have jre. Can you clearly explain what you want to know. JFileChooser is just a UI control in Java, swing component actually. You can use it in Applet, in simple word applet also a Java class embedded on HTML page. (You can view the applet on applet viewer as well.)

    In JSP too, you can use it. But the calling/adding it in JSP and applet are different. I mean the import to your project and so on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •