List of usage examples for javax.swing JFileChooser setFileHidingEnabled
@BeanProperty(preferred = true, description = "Sets file hiding on or off.") public void setFileHidingEnabled(boolean b)
From source file:JFileChooserHidingFiles.java
public static void main(String[] a) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileHidingEnabled(false); fileChooser.showOpenDialog(null);/*from w w w . java2s . c o m*/ }
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); boolean hidingEnabled = chooser.isFileHidingEnabled(); chooser.setFileHidingEnabled(false); chooser.showOpenDialog(null);//from ww w.jav a 2 s . c o m }
From source file:Main.java
/** * Consistent way to chosing multiple files to open with JFileChooser. * <p>/*from ww w. java2 s .c o m*/ * * @see JFileChooser#setFileSelectionMode(int) * @see #getSystemFiles(Component, int) * @param owner to show the component relative to. * @param mode selection mode for the JFileChooser. * @return File[] based on the user selection can be null. */ public static File[] getSystemFiles(Component owner, int mode, FileFilter[] filters) { JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(mode); jfc.setFileHidingEnabled(true); jfc.setMultiSelectionEnabled(true); jfc.setAcceptAllFileFilterUsed(true); if (filters != null) { for (int i = 0; i < filters.length; i++) { jfc.addChoosableFileFilter(filters[i]); } if (filters.length >= 1) { jfc.setFileFilter(filters[0]); } } int result = jfc.showOpenDialog(owner); if (result == JFileChooser.APPROVE_OPTION) { return jfc.getSelectedFiles(); } return new File[0]; }
From source file:Main.java
/** * Consistent way to chosing a file to open with JFileChooser. * <p>/*from ww w.j a v a 2s . c om*/ * * @see JFileChooser#setFileSelectionMode(int) * @see #getSystemFiles(Component, int) * @param owner to show the component relative to. * @param mode selection mode for the JFileChooser. * @return File based on the user selection can be null. */ public static File getSystemFile(Component owner, int mode, FileFilter[] filters) { JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(mode); jfc.setFileHidingEnabled(true); jfc.setAcceptAllFileFilterUsed(true); if (filters != null) { for (int i = 0; i < filters.length; i++) { jfc.addChoosableFileFilter(filters[i]); } if (filters.length >= 1) { jfc.setFileFilter(filters[0]); } } int result = jfc.showOpenDialog(owner); if (result == JFileChooser.APPROVE_OPTION) { return jfc.getSelectedFile(); } return null; }
From source file:com.willwinder.universalgcodesender.uielements.components.FirmwareSettingsFileTypeFilter.java
public static JFileChooser getSettingsFileChooser() { FirmwareSettingsFileTypeFilter filter = new FirmwareSettingsFileTypeFilter(); // Setup file browser with the last path used. JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setFileHidingEnabled(true); fileChooser.addChoosableFileFilter(filter); fileChooser.setAcceptAllFileFilterUsed(true); fileChooser.setFileFilter(filter);// w w w . jav a 2s . c o m return fileChooser; }
From source file:de.dakror.virtualhub.server.dialog.BackupEditDialog.java
public static void show() throws JSONException { final JDialog dialog = new JDialog(Server.currentServer.frame, "Backup-Einstellungen", true); dialog.setSize(400, 250);//from w ww . ja v a 2 s.com dialog.setLocationRelativeTo(Server.currentServer.frame); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); JPanel cp = new JPanel(new SpringLayout()); cp.add(new JLabel("Zielverzeichnis:")); JPanel panel = new JPanel(); final JTextField path = new JTextField((Server.currentServer.settings.has("backup.path") ? Server.currentServer.settings.getString("backup.path") : ""), 10); panel.add(path); panel.add(new JButton(new AbstractAction("Whlen...") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { JFileChooser jfc = new JFileChooser((path.getText().length() > 0 ? new File(path.getText()) : new File(System.getProperty("user.home")))); jfc.setFileHidingEnabled(false); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jfc.setDialogTitle("Backup-Zielverzeichnis whlen"); if (jfc.showOpenDialog(dialog) == JFileChooser.APPROVE_OPTION) path.setText(jfc.getSelectedFile().getPath().replace("\\", "/")); } })); cp.add(panel); cp.add(new JLabel("")); cp.add(new JLabel("")); cp.add(new JButton(new AbstractAction("Abbrechen") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } })); cp.add(new JButton(new AbstractAction("Speichern") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { try { if (path.getText().length() > 0) Server.currentServer.settings.put("backup.path", path.getText()); dialog.dispose(); } catch (JSONException e1) { e1.printStackTrace(); } } })); SpringUtilities.makeCompactGrid(cp, 3, 2, 6, 6, 6, 6); dialog.setContentPane(cp); dialog.pack(); dialog.setVisible(true); }
From source file:com.antelink.sourcesquare.gui.controller.SourceSquareController.java
public void bind() { this.view.getSelectButtonLabel().addMouseListener(new MouseListener() { @Override// w w w . java 2 s .co m public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseClicked(MouseEvent e) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileHidingEnabled(false); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int showDialog = fileChooser.showDialog(SourceSquareController.this.view, "Select directory"); if (showDialog == JFileChooser.APPROVE_OPTION) { SourceSquareController.this.view.getTextField() .setText(fileChooser.getSelectedFile().getAbsolutePath()); } } }); this.view.getScanButtonLabel().addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseClicked(MouseEvent arg0) { File toScan = new File(SourceSquareController.this.view.getTextField().getText()); if (!toScan.exists() || toScan.list().length == 0) { JOptionPane.showMessageDialog(SourceSquareController.this.view, "Choose a valid and not empty directory", null, JOptionPane.ERROR_MESSAGE); return; } SourceSquareController.this.view.setVisible(false); SourceSquareController.this.eventBus.fireEvent(new StartScanEvent(toScan)); } }); }
From source file:my.swingconnect.SwingConnectUI.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed //To BROWSE A FILE FROM THE DIRECTORY JFileChooser chooser = new JFileChooser(); //To enable showing hidden file chooser.setFileHidingEnabled(false); //To Enable selecting directory or files chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); //To enable multiple file selections chooser.setMultiSelectionEnabled(true); //Choice of user to save or open a file chooser.setDialogType(JFileChooser.OPEN_DIALOG); chooser.setDialogTitle("Choose a file..."); //To user to select a file if (chooser.showOpenDialog(SwingConnectUI.this) == JFileChooser.APPROVE_OPTION) { targetFile = chooser.getSelectedFile(); String directory = targetFile.getPath(); jTextField4.setText(targetFile.toString()); // files = new File("/Users/pradil90/Desktop/207dropbox").listFiles(); files = new File(directory).listFiles(); for (File file : files) { if (file.isFile()) { results.add(file.getAbsolutePath()); // results.add(file.getName()); System.out.println(file); count++;/*from www. j a v a2 s.c o m*/ System.out.println(count); } } results.remove(0); jButton3.setEnabled(true); } }
From source file:firmadigital.Firma.java
private void cmdExaminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdExaminarActionPerformed JFileChooser fileChooser = new JFileChooser(); txtUbicacion.setText(""); lblNombreArchivo.setText(""); lblRutaArchivo.setText(""); String signFileName = txtUbicacion.getText(); File directory = new File(signFileName).getParentFile(); fileChooser.setCurrentDirectory(directory); FileNameExtensionFilter filter; filter = new FileNameExtensionFilter("XML file", "xml"); fileChooser.setFileFilter(filter);//from w w w .j av a 2 s . c om fileChooser.setFileHidingEnabled(true); /*Remove All File option*/ fileChooser.setAcceptAllFileFilterUsed(false); if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { String selectedFile = fileChooser.getSelectedFile().getAbsolutePath(); txtUbicacion.setText(selectedFile); lblNombreArchivo.setText(fileChooser.getSelectedFile().getName()); lblRutaArchivo.setText(fileChooser.getSelectedFile().getParent()); } }
From source file:com.nbt.TreeFrame.java
protected JFileChooser createFileChooser() { JFileChooser fc = new JFileChooser(); fc.setFileHidingEnabled(false); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); String description = "named binary tag"; FileFilter filter = new FileNameExtensionFilter(description, "mcr", "dat", "dat_old"); fc.setFileFilter(filter);//from ww w . j a va 2 s . c o m Preferences prefs = getPreferences(); String exportFile = prefs.get(KEY_FILE, null); if (exportFile == null) { File cwd = new File("."); fc.setCurrentDirectory(cwd); } else { File selectedFile = new File(exportFile); fc.setSelectedFile(selectedFile); } return fc; }