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ことにより、txt ファイルをフィルター処理します。FileNameExtensionFilterJFileChooser.setFileFilter(FileFilter)
FileNameExtensionFilter
JFileChooser.setFileFilter(FileFilter)