Is this a bug in javax.swing.JFileChooser?

Discussion in 'Java' started by RC, May 16, 2007.

  1. RC

    RC Guest

    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!
    RC, May 16, 2007
    #1
    1. Advertising

  2. RC

    SadRed Guest

    On May 17, 2:54 am, RC <> wrote:
    > 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.
    SadRed, May 16, 2007
    #2
    1. Advertising

  3. RC

    Daniel Pitts Guest

    On May 16, 10:54 am, RC <> wrote:
    > 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>
    Daniel Pitts, May 17, 2007
    #3
  4. RC

    SadRed Guest

    On May 17, 2:54 am, RC <> wrote:
    > 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.
    SadRed, May 17, 2007
    #4
  5. RC

    Guest

    On May 16, 7:54 pm, RC <> wrote:
    > 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.
    , May 17, 2007
    #5
  6. In article <>,
    "" <> wrote:

    > On May 16, 7:54 pm, RC <> wrote:
    > > 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.
    --
    Steve W. Jackson
    Montgomery, Alabama
    Steve W. Jackson, May 17, 2007
    #6
  7. RC

    ..::WojT::.. Guest

    > 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::..
    ..::WojT::.., May 18, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren
    Replies:
    11
    Views:
    4,514
    Darren
    Oct 27, 2005
  2. lizard
    Replies:
    0
    Views:
    1,753
    lizard
    Jan 30, 2006
  3. S.T
    Replies:
    2
    Views:
    568
  4. Mark Space
    Replies:
    0
    Views:
    376
    Mark Space
    Oct 14, 2008
  5. jimgardener

    need advice using swing jfilechooser

    jimgardener, Oct 27, 2010, in forum: Java
    Replies:
    6
    Views:
    792
    jimgardener
    Oct 28, 2010
Loading...

Share This Page