如何设置默认文件名到Swing JFileChooser? [英] How to set a default file name to Swing JFileChooser?

查看:198
本文介绍了如何设置默认文件名到Swing JFileChooser?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在这个 JFileChooser 的文本框中设置默认文件名为 Untitled.txt 。我可以设置这个吗?

I want to set a default file name as Untitled.txt in text-box of this JFileChooser. Can I set this?

推荐答案

使用下面的代码:

Use the following code:

        JFileChooser fileChooser = new JFileChooser();
        File file = new File("C:/untitled.txt");
        fileChooser.setCurrentDirectory(file);

您必须指定 untitled.txt

这篇关于如何设置默认文件名到Swing JFileChooser?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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