Results 1 to 6 of 6
  1. #1
    santhosh_el is offline Member
    Join Date
    Feb 2009
    Posts
    50
    Rep Power
    0

    Default Regarding issue in jfilechooser

    private void filebuttonActionPerformed(java.awt.event.ActionEve nt evt) {
    // TODO add your handling code here:

    String memname1="";
    String selmem1="";
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new File(".."));

    chooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
    public boolean accept(File f) {
    return f.getName().toLowerCase().endsWith(".txt")
    || f.isDirectory();
    }

    public String getDescription() {
    return "All Files";
    }
    });
    int r = chooser.showOpenDialog(new JFrame());
    if (r == JFileChooser.APPROVE_OPTION) {
    // String name = chooser.getSelectedFile().getName();
    File file = chooser.getSelectedFile();
    memname1=file.toString();
    selmem1=file.getName();

    System.out.println("selmem1" +":" +selmem1);
    System.out.println("memname" + ":"+ memname1);

    filetext.setText(memname1);
    }



    }

    dear sir,

    this is the test to select a file using jfilechooser.my problem is jfilechooser took 1 minute to open dialogbox on my machine and in another machine took
    2 secs . i am uisng ide is netbeans 6.5.can anybody solve my problem pls its urgent .

    thanks
    santhosh babu

    thanks
    santhosh babu

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

    Default

    Seems to me, in your code nothing wrong. It must take very short time period to execute. So I guess this is related with the hardware you are using. Can you let me what are the memory you have in two PCs.

  3. #3
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    First, you can pass "null" instead of creating a new JFrame. That will certainly save some time.

    Try this:

    long start = System.currentTimeMillis();

    Then put some copies of the following at various places in your code:

    System.out.println("Time: " + (System.currentTimeMillis() - start));

    That will print the number of milliseconds that have elapsed. This will show you which statements are taking a long time to execute. If one statement is taking a long time, examine it to determine why. You may find that something is making getting Java started take a long time, as well.

  4. #4
    santhosh_el is offline Member
    Join Date
    Feb 2009
    Posts
    50
    Rep Power
    0

    Default Regarding issue in jfilechooser

    dear sir,

    thanks for your advice and i have make chahges in my code.

    suppose i will run the code in another system its taking around 1 minutes to open dialog window ,but in my system its takes around 1 secs to open dialog window . i have installed jdk1.5.0_14 and jdk1.6.0_04. pls give me any solution.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default

    There is a known issue with JFileChooser taking a long time to display on Windows, when there are large zip files in the default directory. Is that the case here?

    db

  6. #6
    santhosh_el is offline Member
    Join Date
    Feb 2009
    Posts
    50
    Rep Power
    0

    Default Regarding issue in jfilechooser

    dear sir,

    my issue in jfilechooser taking long time to display on windows.how to solve this problem.
    thanks
    santhosh babu

Similar Threads

  1. using jfilechooser
    By jagadhguru in forum AWT / Swing
    Replies: 3
    Last Post: 10-30-2008, 12:17 PM
  2. Help With JavaSwing - JFileChooser
    By mystified in forum AWT / Swing
    Replies: 18
    Last Post: 09-24-2008, 02:23 AM
  3. Need JFileChooser Help
    By Wraithier in forum New To Java
    Replies: 4
    Last Post: 06-18-2008, 05:40 PM
  4. Localize JFileChooser
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-14-2008, 11:54 AM
  5. how to use JFileChooser
    By tommy in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 08:49 PM

Posting Permissions

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