Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-28-2009, 09:39 AM
Member
 
Join Date: Feb 2009
Posts: 51
Rep Power: 0
santhosh_el is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 05-28-2009, 11:27 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,481
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-29-2009, 03:39 AM
Steve11235's Avatar
Senior Member
 
Join Date: Dec 2008
Posts: 967
Rep Power: 2
Steve11235 is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-29-2009, 07:28 AM
Member
 
Join Date: Feb 2009
Posts: 51
Rep Power: 0
santhosh_el is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-30-2009, 09:35 AM
Darryl.Burke's Avatar
Senior Member
 
Join Date: Sep 2008
Location: Madgaon, Goa, India
Posts: 722
Rep Power: 2
Darryl.Burke is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 06-01-2009, 07:59 AM
Member
 
Join Date: Feb 2009
Posts: 51
Rep Power: 0
santhosh_el is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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
using jfilechooser jagadhguru AWT / Swing 3 10-30-2008 01:17 PM
Help With JavaSwing - JFileChooser mystified AWT / Swing 18 09-24-2008 03:23 AM
Need JFileChooser Help Wraithier New To Java 4 06-18-2008 06:40 PM
Localize JFileChooser Java Tip Java Tips 0 03-14-2008 12:54 PM
how to use JFileChooser tommy New To Java 1 08-06-2007 09:49 PM


All times are GMT +2. The time now is 10:54 PM.



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