English 中文(简体)
如何使用操作系统的默认文件选择器?
原标题:How to use the default file chooser for the operating system?

我只是想知道: Gmail 如何使用 Windows/ Mac 文件选择器上传文件? 在 Java 上传文件有什么办法吗?

就个人而言,我不喜欢 JFileChooser 看上去的样子,我认为我的用户最好能够使用他们更习惯使用的东西。 提示谁?

最佳回答

使用旧的 java.awt.

new java.awt.FileDialog((java.awt.Frame) null).setVisible(true);
问题回答

你可以尝试使用 JFileChoooser,但设置外观和感觉 成为平台的外观和感觉:

    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }catch(Exception ex) {
        ex.printStackTrace();
    }

这样所有摆动部件都会更漂亮!

GMail 是一个最终依靠浏览器显示此组件的网络应用程序。 现在一个很好的解决方案是使用“ 本地 Look& Feel” 系统, 提供与您显示的类似 JFileChooser 的 JFileChooser 系统 :

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

"https://i.sstatic.net/kgzRi.png" alt="此处的内置图像描述"/ >

脉冲星的解决方案更好,因为它提供了您正在寻找的精确对话框。 我不确定它是否提供了 JFileChooser 的所有功能 。

< a href=" "http://en.wikipedia.org/wiki/Standard_Wifet_Toolkit" rel = "no follow" >SWT 组件总是看起来与运行中的 OS 中相同的样式。 您可以看到一些例子 :

假定从爪哇第七版起,摇摆风格更像操作系统,但在爪哇八版中可以看到。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签