How to open JFileChooser from menu item actionPerformed?
Like in title how to make happen that when I click on menu item should open JFileChooser to select *.txt file?
I'm try开发者_运维问答ing this ActionListener but don't know how to use is to make it work: could you give me some lead?
Add an ActionListener to the JMenuItem. In the actionPerformed(ActionEvent) method, open the JFileChooser.
When making the JFileChooser, cause it to filter for txt files by creating an appropriate FileNameExtensionFilter and calling JFileChooser.setFileFilter(FileFilter) using that filter.
加载中,请稍侯......
精彩评论