Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / May 2007

Tip: Looking for answers? Try searching our database.

Is this a bug in javax.swing.JFileChooser?

Thread view: 
RC - 16 May 2007 18:54 GMT
When I open a JFileChooser.
If I SINGLE click a directory and click the Open button.
Then I got return $paths/selected_directory.

That is good!

However if I DOUBLE click a directory and click the Open button.
Then I got return $paths/selected_directory/selected_directory

Why I got selected_directory twice from return?
Is this a bug or I missed somethings?

Do you have a solution for that?
Thank Q very much in advance!
SadRed - 16 May 2007 23:58 GMT
> When I open a JFileChooser.
> If I SINGLE click a directory and click the Open button.
[quoted text clipped - 10 lines]
> Do you have a solution for that?
> Thank Q very much in advance!

>  Then I got return $paths/selected_directory/selected_directory
It was:
$paths/selected_directory/another_selected_directory(or file)
and a normal behavior of the JFileChooser GUI.
Daniel Pitts - 17 May 2007 00:23 GMT
> When I open a JFileChooser.
> If I SINGLE click a directory and click the Open button.
[quoted text clipped - 10 lines]
> Do you have a solution for that?
> Thank Q very much in advance!

If you notice, when you first click the directory, the name appears in
the text field.
When you double click, you enter that directory, but the name stays in
the text field.

The name staying in the text field is definitely what causes your
described behavior.
<sscce>
import javax.swing.*;
public class FileChoo {
   public static void main(String[] args) {
       final JFileChooser jFileChooser = new JFileChooser();

jFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
       jFileChooser.showOpenDialog(null);
       System.out.println("file = " +
jFileChooser.getSelectedFile());
   }
}
</sscce>
Andrew Thompson - 17 May 2007 04:01 GMT
...
>If you notice, when you first click the directory, the name appears in
>the text field.
>When you double click, you enter that directory, but the name stays in
>the text field.

(snip code)

Using that code, and Java 1.6 on XP, I could not reproduce
the behaviour described.  In all combinations of single or
double clicks, the chooser correctly identified the directory
I was opening.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Daniel Pitts - 17 May 2007 19:30 GMT
> ..
>
[quoted text clipped - 9 lines]
> double clicks, the chooser correctly identified the directory
> I was opening.
On RedHat Linux, Java 5, I was able to reproduce the OP's "problem".
So, apparently its been fixed in 1.6.

Daniel.
SadRed - 17 May 2007 04:21 GMT
> When I open a JFileChooser.
> If I SINGLE click a directory and click the Open button.
[quoted text clipped - 10 lines]
> Do you have a solution for that?
> Thank Q very much in advance!

If it is
$paths/selected_directory/another_selected_directory_or_file
that is a normal behavior of the JFileChooser GUI.
a24900@googlemail.com - 17 May 2007 09:50 GMT
> Why I got selected_directory twice from return?
> Is this a bug or I missed somethings?

JFileChooser is broken in many twisted ways. Sun says this is how it
has to be and closed all related bug reports.
Steve W. Jackson - 17 May 2007 15:45 GMT
> > Why I got selected_directory twice from return?
> > Is this a bug or I missed somethings?
>
> JFileChooser is broken in many twisted ways. Sun says this is how it
> has to be and closed all related bug reports.

Nice opinion.  Now back it up with some examples of what's broken.  I've
been using it successfully for some years now and don't find any major
issues with it.
Signature

Steve W. Jackson
Montgomery, Alabama

..::WojT::.. - 18 May 2007 07:40 GMT
> Nice opinion.  Now back it up with some examples of what's broken.  I've
> been using it successfully for some years now and don't find any major
> issues with it.

Are You really sure ;) ?
What about this annoying bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050516

..::WojT::..


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.