开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜