Desktop ShortCut folder problem in JFileChooser

Discussion in 'Java' started by Proton Projects - Moin, Sep 20, 2007.

  1. Hi all,

    I have Browse button and on clicking it, it will open a JFileChooser.
    Filtering property is set to Directories only. Approve button named to

    I have created the desktop shortcut to one my folder. I launched the
    JFileChooser and home button takes me to the desktop. On clicking the
    shortcut folder, JFileChooser automatically changes my approve button
    name from "import" to "open" and clicking on approve button (i.e. now
    it is "open") and JFileChooser get into the actual path of the
    shortcut folder and now my approve button changes to "import". This
    works perfect.

    Problem Scenario:
    Once again I launched the JFileChooser and instead of clicking the
    home button, i used the drop down list to select the shortcut folder
    directly. JFileChooser did not change my approve button name from
    "import" to "open" and clicking on approve button (i.e. "import"),
    nothing is happening and it shows me an empty directory.

    Is it bug with JFileChooser or do I need to do any extra setting to
    get rid of these short cut issues.

    Please assist me

    Proton Projects - Moin, Sep 20, 2007
    1. Advertisements

  2. Proton Projects - Moin wrote:
    Is that a question? If so, please remember to add a
    question mark at the end.

    Also, it might help to get answers if you can provide
    a code sample that demonstrates this behaviour. By
    that, I specifically mean an SSCCE, rather than 'code

    Andrew Thompson

    Message posted via
    Andrew Thompson, Sep 21, 2007
    1. Advertisements

  3. Thanks for your comment and follow it in future.

    Kindly assist me for my original post of Desktop ShortCut folder
    problem in JFileChooser.

    Code is

    public class ProjectChooser extends JFileChooser
    private static String previousUrl = null;
    public ProjectChooser(PropertiesDialog parent, String
    if(previousUrl == null)
    setCurrentDirectory(new File(directoryPath));
    setCurrentDirectory(new File(previousUrl));
    //addChoosableFileFilter(new NpsProjectFilter());

    final SelectProjectController selectProjectController =
    (SelectProjectController) parent.propertiesController;

    addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)

    previousUrl =

    showDialog(parent, "Import");
    JDialog dialog = createDialog(parent);
    Proton Projects - Moin, Sep 21, 2007
  4. Great, but.. what you posted is *not* an SSCCE.

    An SSCCE is supposed to be compilable and runnable
    to show the problem on-screen for others, but even after
    I add the imports, I still get compilation errors due to
    references to custom classes that are not included.
    Namely PropertiesDialog, SelectProjectController
    & NpsProjectFilter.

    That example would also need a small 'main()',
    to allow it to be runnable.

    For a further description of the SSCCE, see..

    Andrew Thompson

    Message posted via
    Andrew Thompson, Sep 21, 2007
  5. Proton Projects - Moin


    Unsurprising, since you never explained to him what an SSCCE *is*.
    We're not born knowing. Regulars here all know, but the OP is
    obviously not one. Perhaps if your first post to the thread had
    explained what an SSCCE was or at least linked to that
    page, it would have helped? :)
    , Sep 21, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.