我正在为 pdf 阅读器创建用户界面,并且我想要一个包含最近打开的文件的列表。 (不是文件的内容,只是文件的名称)。
最佳答案
从共享的快照中,我假设您正在使用 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/