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 / General / September 2007

Tip: Looking for answers? Try searching our database.

Desktop ShortCut folder problem in JFileChooser

Thread view: 
Proton Projects - Moin - 20 Sep 2007 15:08 GMT
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
Andrew Thompson - 21 Sep 2007 05:05 GMT
...
>Is it bug with JFileChooser or do I need to do any extra setting to
>get rid of these short cut issues.

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

Signature

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

Proton Projects - Moin - 21 Sep 2007 09:29 GMT
> ..
>
[quoted text clipped - 13 lines]
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1

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);
*/
       }
Andrew Thompson - 21 Sep 2007 09:44 GMT
>> ..
>> (SSCCE)
...
>Thanks for your comment and follow it in future.

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>

Signature

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

nebulous99@gmail.com - 21 Sep 2007 14:36 GMT
> >> ..
> >> (SSCCE)
> ..
> >Thanks for your comment and follow it in future.
>
> Great, but.. what you posted is *not* an SSCCE.

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? :)


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



©2009 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.