Java Select File in windows Explorer?
I am working on a Java GUI, in which i have a JTable in which i have populated my file system, on JTable i have a Right Click Context Menu Like This
i right click on m开发者_Python百科y File and it opens this folders in windows Explorer, to open a file/folder in windows explorer i am using this code
Desktop desktop = Desktop.getDesktop();
if (Desktop.isDesktopSupported()) {
}
try {
desktop.open(myFile); //myFile is my Selected File
} catch (IOException e) {
}
This opens myFile in windows Explorer Like this
i want that it should open windows and my file should be selected in windows explorer.
Thanks
See this: Open the windows explorer with a file selected in eclipse
If you want, for example, select the folder (let's say) C:\myFolder, just replace the arguments with:
/select,C:\myFolder
Do you think you know which options to use? ;)
EDIT: whoops, it looks like you don't call explorer by executing it. Desktop class seems have no support for specifying options/parameters, so I guess this is not doable without using Process class.
精彩评论