• category: swing folder: FileHidingEnabled title: JFileChooserでの隠しファイルの非表示設定を変更する tags: [JFileChooser, JPopupMenu] author: aterai pubdate: 2014-03-17T00:01:02+09:00 description: JFileChooserで隠しファイルを表示するかどうかをポップアップメニューから切り替えます。 image: https://lh4.googleusercontent.com/-TSMPljQ02Ao/UyWixahVFzI/AAAAAAAACBw/n_Ctee0FJGQ/s800/FileHidingEnabled.png

概要

JFileChooserで隠しファイルを表示するかどうかをポップアップメニューから切り替えます。

サンプルコード

chooser = new JFileChooser();
JPopupMenu pop = searchPopupMenu(chooser);
pop.addSeparator();
JCheckBoxMenuItem mi = new JCheckBoxMenuItem(new AbstractAction("isFileHidingEnabled") {
  @Override public void actionPerformed(ActionEvent e) {
    chooser.setFileHidingEnabled(((JCheckBoxMenuItem) e.getSource()).isSelected());
  }
});
mi.setSelected(chooser.isFileHidingEnabled());
pop.add(mi);
View in GitHub: Java, Kotlin

解説

上記のサンプルでは、JFileChooser#setFileHidingEnabled(boolean)メソッドを使用して、隠しファイル、隠しフォルダーなどの表示・非表示を設定しています。

参考リンク

コメント