I made a program to search for .txt files.
If I click a file it means that the "open with" dialog box should appear, and that dialog box will contain a list of all installed programs.
I am using this code for searching through the files:
public File[] finder( String dirName)
{
// Create a file object on the directory.
File dir = new File(dirName);
// Return a list of all files in the directory.
return dir.listFiles(new FilenameFilter();
}
public boolean accept(File dir, String filename)
{
return filename.endsWith(".txt");
}
What Java code can I use to make the "open with" dialog box appear?
You can make your own dialog for that purpose .And for coming how to get program list .on windows you can use registry . see this link Detecting installed programs via registry
and also check how to acces registry via java read/write to Windows Registry using Java
To my knowledge, there is nothing in the J2SE like that. OTOH the
Desktop
API can open aFile
in whatever app. is the default consumer.You should use
FileChooser
for this. Take a look here: