如何预填充JFileChooser将“文件名"? [英] How to pre-populate a JFileChooser will "filename"?

查看:52
本文介绍了如何预填充JFileChooser将“文件名"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算用数据库中的名称填充JFileChooser,但使用标准的JFileChooser对话框进行加载,删除,保存和另存为.我想给用户一种印象,他们正在使用文件系统,而在后端使用数据库来保存更改.用户应该无法浏览到其他目录以进行保存或另存为.我想使用相同的JFileChooser对话框,但带有一个取消按钮和另一个按钮(删除|保存|另存为|加载).

I intend to populate a JFileChooser with names from a database but use the standard JFileChooser Dialog for load, delete, save and save-as. I want to give users an impression that they are working on a file system whereas am using a database at the backend to save changes. The user should not be able to browse to a different directory to save or save as. I want to use the same JFileChooser Dialog but with a cancel button and another button(delete|save|save as|load).

推荐答案

无法使用JFileChooser完成.

Can't be done using the JFileChooser.

JFileChooser仅在java.io.File上运行.为此,您必须继承java.io.File的子类,并创建某种非常丑陋的假文件系统.

JFileChooser only operates on java.io.File's. To do this you would have to subclass java.io.File and create some kind of fake file system that would be very ugly.

您将必须制作自己的保存对话框组件或找到另一个要使用的类似组件. JFileChooser不是您想要的.

You are going to have to make your own save dialog component or find another similar component to use. JFileChooser isnt what you want.

这篇关于如何预填充JFileChooser将“文件名"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆