cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sumodevarghese
Level 3

How can i create a "Browse For Folder" dialog.

Hi All,

Please help me in creating a "Browse for Folder" Dialog through Custom Code so that I can browse and select the necessary directory.

If anybody have the code snippets, please share.


Thanks
Sumode
Labels (1)
0 Kudos
(6) Replies
kpant13
Level 3

First write a java class which extends from CustomCodePanel class and
import package com.zerog.ia.api.pub.*;
Use netbeans ide and create a simple jpanel and add button. then copy the autogenerated code to ur class .
Add a listener to button and on event write code to create JFileChooser
and setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) as following

final JFileChooser fc = new JFileChooser();
JList list = new JList();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (JFileChooser.APPROVE_OPTION == fc.showOpenDialog(list)) {
File file = fc.getSelectedFile();
}
0 Kudos
sumodevarghese
Level 3

Thanks for the reply.

Here the dialog window which get open is different from the standard InstallAnywhere's directory browse dialog.

How can I get the standard one?
Attached the image,
0 Kudos
kpant13
Level 3

hi,

You have to create a jni library which contains a method which uses native
api to display Browse for folder dialog.At present the dialog which u see is displayed using Swing.
I was facing the same problem but for Mac.
So I created a jni library which force java to use awt to display BrowseDilaog.
Now I am succeeded but the only problem is I have to put this library manually inside app directory.U can go through the my previous post on 31 october.

If you find any other way to diaplay standard browse folder dialog box please let me also know.
Thanks,
-kpant
0 Kudos
sumodevarghese
Level 3

Thanks for the information.

Is there any custom code APIs (known) available to create the 'Browse For Folder' dialog?

Sumode
0 Kudos
kpant13
Level 3

Hi,
I am feeling very great that I have solved this problem for Mac OS.
I wrote a method ExtractFromJar to extract my jnilib from jar.
The first dialog box is displayed using Swing.
The second dialog box is displayed via a jni library which uses native mac API's.

Soon I will be doing the same for windows.
0 Kudos
Singaravelan
Level 4

Copy the logic already built in the default dialog for the folder selection.
You can find it in the list of dialogs in the IDE.
0 Kudos