Desktop ShortCut folder problem in JFileChooser

  • Thread starter Proton Projects - Moin
  • Start date
P

Proton Projects - Moin

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
 
A

Andrew Thompson

Proton Projects - Moin wrote:
...
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'.

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

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
 
P

Proton Projects - Moin

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

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);
*/
}
 
A

Andrew Thompson

Proton said:
...
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>

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

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
 
N

nebulous99

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

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top