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
    "import".

    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

    Thanks
    Moin
     
    Proton Projects - Moin, Sep 20, 2007
    #1
    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
    snippets'.

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

    Message posted via JavaKB.com
    http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
     
    Andrew Thompson, Sep 21, 2007
    #2
    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
    directoryPath)
    {
    if(previousUrl == null)
    {
    setCurrentDirectory(new File(directoryPath));
    }
    else
    {
    setCurrentDirectory(new File(previousUrl));
    }
    //addChoosableFileFilter(new NpsProjectFilter());
    setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    setApproveButtonText("Import");

    final SelectProjectController selectProjectController =
    (SelectProjectController) parent.propertiesController;

    addActionListener(new ActionListener()
    {
    public void actionPerformed(ActionEvent ae)
    {
    if
    (ae.getActionCommand().equalsIgnoreCase("ApproveSelection"))
    {
    if(new
    NpsProjectFilter().accept(getSelectedFile()))
    {

    selectProjectController.setUrl(getSelectedFile().getAbsolutePath());
    previousUrl =
    getSelectedFile().getAbsolutePath();
    }
    }
    }
    });

    showDialog(parent, "Import");
    /*
    JDialog dialog = createDialog(parent);
    dialog.setVisible(true);
    */
    }
     
    Proton Projects - Moin, Sep 21, 2007
    #3
  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..
    <http://www.physci.org/codes/sscce.html>

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

    Message posted via JavaKB.com
    http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
     
    Andrew Thompson, Sep 21, 2007
    #4
  5. Proton Projects - Moin

    Guest

    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 physci.org
    page, it would have helped? :)
     
    , Sep 21, 2007
    #5
    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.