I making an app in Java. I want an Open With Dialog to appear when a JButton is clicked.

I know that in Windows, the contents of the Recommended Programs list are determined from the registry entry

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\filetype\OpenWithList

..where 'filetype' is the required file type.

Is there any way that this can be done with complete independence of the OS in which this app runs? Or do I have to get the OS name and program accordingly?

有帮助吗?

解决方案

Not completely sure whether this answer will be relevant as I am making some assumptions. In case it is a file you want to open, you can use Desktop#open which will open the File with the default application.

I assume (but did not test) that when no default application is set, a dialog will be shown asking what application you want to use to open that file (similar as when you double click such a file in your file browser).

This is not completely what you asked for, but might be sufficient.

Otherwise I am afraid I agree with Andrew's answer that there is no general way to do this.

其他提示

Is there any way that this can be done with complete independence of the OS in which this app runs?

No.

Or do I have to get the OS name and program accordingly?

Yes.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top