Is this a bug in javax.swing.JFileChooser?

R

RC

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!
 
S

SadRed

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!
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.
 
D

Daniel Pitts

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!

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>
 
S

SadRed

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!

If it is
$paths/selected_directory/another_selected_directory_or_file
that is a normal behavior of the JFileChooser GUI.
 
A

a24900

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.
 
S

Steve W. Jackson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top