gpt4 book ai didi

java - 如何保存文件名然后使其出现在文本区域中

转载 作者:行者123 更新时间:2023-11-30 02:56:17 25 4
gpt4 key购买 nike

我正在为 pdf 阅读器创建用户界面,并且我想要一个包含最近打开的文件的列表。 (不是文件的内容,只是文件的名称)。

This is my picture

最佳答案

从共享的快照中,我假设您正在使用 JFileChooser 作为对话框来打开文件。希望这有帮助!

int result = fileChooser.showOpenDialog(panel);
//where panel is an instance of a Component such as JFrame, JDialog or JPanelwhich is parent of the dialog.
if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
textArea.setText(selectedFile.getName());
}

关于java - 如何保存文件名然后使其出现在文本区域中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37150527/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com