4

我有一个 java 应用程序,它在某个阶段使用 JFileChooser.showOpenDialog() 从本地文件系统中选择文件。

现在我希望它在客户端-服务器设置中。这意味着打开一个 GUI(文件浏览器)来选择服务器上的文件。我已经尝试了几种方案来继续使用 JFileChooser,但我无法让正确的设置正常工作。

如果我知道文件浏览器需要预先默认的路径,有谁知道如何在远程服务器上构建文件浏览器?例如:如果服务器地址是“http://sand.int.group.com:9083”,并且在这个地址上,我想要默认的目录位于“/home/myDir/”。如何显示文件浏览器窗口,以便它列出位于此服务器目录中的文件?

4

3 回答 3

4

JFileChooser无法加载网址。您需要在要浏览文件的机器上映射网络共享。

于 2011-03-07T19:13:54.957 回答
1

我相信这将为您服务:http: //vfsjfilechooser.sourceforge.net/index.html

基于 JFileChooser 代码的远程文件选择器...

于 2012-02-22T11:19:37.863 回答
0

AFAIK this is not working out of the box. The local JFileChooser has no idea about files located on server side.

Take WebSphere for example, with the Websphere admin tool you can deploy local EAR/WAR files to the server, IBM is doing this with a JFileChooser. But when you are going to deploy a file which is on the remote server you get a completely different UI. So it seems to be very tricky.

One possible way might be to implement your own FileSystemView, but I am not sure, this is just an idea.

于 2011-03-07T19:19:03.097 回答