Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
就像标题中一样,当我单击菜单项时应该打开JFileChooser以选择 *.txt 文件时,如何做到这一点?
JFileChooser
我正在尝试这个ActionListener,但不知道如何使用它来使它工作:你能给我一些线索吗?
ActionListener
在. ActionListener_ JMenuItem在actionPerformed(ActionEvent)方法中,打开JFileChooser.
JMenuItem
actionPerformed(ActionEvent)
制作时JFileChooser,通过创建适当的FileNameExtensionFilter并使用该过滤器调用来过滤 txt 文件JFileChooser.setFileFilter(FileFilter)。
FileNameExtensionFilter
JFileChooser.setFileFilter(FileFilter)