I want to open a folder when i click a button ..

What is the command for that??

plz help...

(thing is i jst don't wanna complex thing like file chooser ..jst want to open a paticular folder given by a path.)

Recommended Answers

All 3 Replies

An actionListener that opens a JDialog, but you'll have to create your own "view".

An actionListener that opens a JDialog, but you'll have to create your own "view".

I didn't really understood what you hv said!!!

I found something like this....(And it WORKED!!!:))

String a="C:\\";

Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL \""+a+"\"");

I feel theres smthing wrong there!!!!! But it worked...

That is definately not what you want. Look at the File class, it's listFiles() method, design an icon for each "filetype", add an actionlistener to this "button", and with that actionlistener, open a JDialog. On that JDialog place the icons.

There is not a "one-click" solution to this, unless you use JFileChooser. That is the only "folder displayer" in the Swing arsenal that I am aware of. Any other view you will have to do yourself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.