开发者

How to open JFileChooser from menu item actionPerformed?

开发者 https://www.devze.com 2023-02-22 16:55 出处:网络
Like in title how to make happen that when I click on menu item should open JFileChooser to select *.txt file?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消