문제

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