Java Code Examples for javax.swing.JFileChooser#DIRECTORIES_ONLY
The following examples show how to use
javax.swing.JFileChooser#DIRECTORIES_ONLY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileSave.java From triplea with GNU General Public License v3.0 | 6 votes |
public FileSave(final String title, final String name, final File currentDirectory) { this( title, name, currentDirectory, JFileChooser.DIRECTORIES_ONLY, null, new FileFilter() { @Override public boolean accept(final File f) { return f.isDirectory(); } @Override public String getDescription() { return "Folder To Save In"; } }); }
Example 2
Source File: WorldBrowserLine.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
public WorldBrowserLine(Frame parent) { // Try and find a single player world to default to File worldDir = null; for (int i=0; i<5; i++) { File dir = Minecraft.findWorldDir(i); if (Minecraft.isValidWorldDir(dir.toPath())) { worldDir = dir; break; } } line = new FileBrowserLine(parent, "World: ", "Open", worldDir, JFileChooser.DIRECTORIES_ONLY, null); line.setFileListener( new FileChangedHandler() ); onInternalFileChanged(); }
Example 3
Source File: FileChooserBuilderTest.java From netbeans with Apache License 2.0 | 5 votes |
/** * Test of setDirectoriesOnly method, of class FileChooserBuilder. */ public void testSetDirectoriesOnly() { FileChooserBuilder instance = new FileChooserBuilder("x"); boolean dirsOnly = instance.createFileChooser().getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY; assertFalse(dirsOnly); instance.setDirectoriesOnly(true); dirsOnly = instance.createFileChooser().getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY; assertTrue(dirsOnly); }
Example 4
Source File: DelegatingChooserUI.java From netbeans with Apache License 2.0 | 5 votes |
/** Returns dirchooser for DIRECTORIES_ONLY, default filechooser for other * selection modes. */ private static Class<?> getCurChooser (JFileChooser fc) { if (fc.getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) { return DirectoryChooserUI.class; } return Module.getOrigChooser(); }
Example 5
Source File: ChromeDownloader.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
public ChromeDownloader() { setTitle("Chrome Plugin"); setIconImage(MTGConstants.ICON_CHROME.getImage()); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setLocationRelativeTo(null); JPanel panelCenter = new JPanel(); getContentPane().add(panelCenter, BorderLayout.CENTER); txtDirectory = new JTextFieldFileChooser(30,JFileChooser.DIRECTORIES_ONLY,System.getProperty("user.home")); panelCenter.add(txtDirectory); JPanel panelButtons = new JPanel(); getContentPane().add(panelButtons, BorderLayout.SOUTH); JButton btnCancel = new JButton(MTGConstants.ICON_DELETE); btnCancel.addActionListener(ae->dispose()); panelButtons.add(btnCancel); JButton btnExport = new JButton(MTGConstants.ICON_EXPORT); btnExport.addActionListener(e-> { try { FileTools.copyDirJarToDirectory(MTGConstants.MTG_CHROME_PLUGIN_DIR, txtDirectory.getFile()); MTGControler.getInstance().notify(new MTGNotification("Export", "Plugin copied in " + txtDirectory.getFile(), MESSAGE_TYPE.INFO)); dispose(); } catch (Exception e1) { logger.error("error extracting files ",e1); MTGControler.getInstance().notify(e1); } }); panelButtons.add(btnExport); pack(); }
Example 6
Source File: OutputBrowserLine.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
public OutputBrowserLine(Frame parent) { // TODO: Remember last output directory? // .. line = new FileBrowserLine(parent, "Output folder:", "Open", new File(""), JFileChooser.DIRECTORIES_ONLY, null); line.setFileListener( new FileChangedHandler() ); }
Example 7
Source File: FileEditor.java From netbeans with Apache License 2.0 | 4 votes |
/** * This method is called by the IDE to pass * the environment to the property editor. * @param env Environment passed by the ide. */ public void attachEnv(PropertyEnv env) { this.env = env; // clearing to defaults directories = true; files = true; fileFilter = null; fileHiding = false; Object dirs = env.getFeatureDescriptor().getValue(PROPERTY_SHOW_DIRECTORIES); if (dirs instanceof Boolean) { directories = ((Boolean)dirs).booleanValue(); } // XXX else if != null, warn Object fil = env.getFeatureDescriptor().getValue(PROPERTY_SHOW_FILES); if (fil instanceof Boolean) { files = ((Boolean)fil).booleanValue(); } // XXX else if != null, warn Object filter = env.getFeatureDescriptor().getValue(PROPERTY_FILTER); if (filter instanceof FilenameFilter) { fileFilter = new DelegatingFilenameFilter((FilenameFilter)filter); } else if (filter instanceof javax.swing.filechooser.FileFilter) { fileFilter = (javax.swing.filechooser.FileFilter)filter; } else if (filter instanceof java.io.FileFilter) { fileFilter = new DelegatingFileFilter((java.io.FileFilter)filter); } // XXX else if != null, warn Object curDir = env.getFeatureDescriptor().getValue(PROPERTY_CURRENT_DIR); if (curDir instanceof File) { currentDirectory = (File)curDir; if(! currentDirectory.isDirectory()) { Logger.getAnonymousLogger().warning("java.io.File will not accept currentDir=" + currentDirectory); // NOI18N currentDirectory = null; } } // XXX else if != null, warn Object baseDir = env.getFeatureDescriptor().getValue(PROPERTY_BASE_DIR); if(baseDir instanceof File) { baseDirectory = (File)baseDir; // As baseDir accept only directories in their absolute form. if(!baseDirectory.isDirectory() || !baseDirectory.isAbsolute()) { Logger.getAnonymousLogger().warning("java.io.File will not accept baseDir=" + baseDirectory); // NOI18N baseDirectory = null; } } // XXX else if != null, warn if (files) { mode = directories ? JFileChooser.FILES_AND_DIRECTORIES : JFileChooser.FILES_ONLY; } else { mode = directories ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_AND_DIRECTORIES; // both false, what now? XXX warn } Object fileHide = env.getFeatureDescriptor().getValue(PROPERTY_FILE_HIDING); if (fileHide instanceof Boolean) { fileHiding = ((Boolean)fileHide).booleanValue(); } if (env.getFeatureDescriptor() instanceof Node.Property){ Node.Property prop = (Node.Property)env.getFeatureDescriptor(); editable = prop.canWrite(); } }
Example 8
Source File: WebSiteGeneratorDialog.java From MtgDesktopCompanion with GNU General Public License v3.0 | 4 votes |
public WebSiteGeneratorDialog(List<MagicCollection> cols) { setSize(new Dimension(571, 329)); setModal(true); setTitle(MTGControler.getInstance().getLangService().getCapitalize("GENERATE_WEBSITE")); setIconImage(MTGConstants.ICON_WEBSITE.getImage()); getContentPane().setLayout(new BorderLayout(0, 0)); JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.NORTH); File f = new File(MTGConstants.MTG_TEMPLATES_DIR); List<String> arrayTemplates = new ArrayList<>(); for (File temp : f.listFiles()) arrayTemplates.add(temp.getName()); cboTemplates = UITools.createCombobox(arrayTemplates); panel.add(cboTemplates); txtDest = new JTextFieldFileChooser(20,JFileChooser.DIRECTORIES_ONLY,MTGControler.getInstance().get("default-website-dir")); panel.add(txtDest); JPanel panneauBas = new JPanel(); getContentPane().add(panneauBas, BorderLayout.SOUTH); JButton btnGenerate = new JButton(MTGControler.getInstance().getLangService().getCapitalize("START")); panneauBas.add(btnGenerate); JPanel panneaucentral = new JPanel(); getContentPane().add(panneaucentral, BorderLayout.CENTER); GridBagLayout gblpanneaucentral = new GridBagLayout(); gblpanneaucentral.columnWidths = new int[] { 258, 258, 0 }; gblpanneaucentral.rowHeights = new int[] { 35, 191, 0 }; gblpanneaucentral.columnWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; gblpanneaucentral.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; panneaucentral.setLayout(gblpanneaucentral); JLabel lblChooseYourCollections = new JLabel( MTGControler.getInstance().getLangService().getCapitalize("CHOOSE_COLLECTIONS") + " :"); GridBagConstraints gbclblChooseYourCollections = UITools.createGridBagConstraints(null, null, 0, 0); panneaucentral.add(lblChooseYourCollections, gbclblChooseYourCollections); JLabel lblChooseYourPrices = new JLabel( MTGControler.getInstance().getLangService().getCapitalize("CHOOSE_PRICER") + " :"); GridBagConstraints gbclblChooseYourPrices = UITools.createGridBagConstraints(null, null,1, 0); panneaucentral.add(lblChooseYourPrices, gbclblChooseYourPrices); list = new JList<>(cols.toArray(new MagicCollection[cols.size()])); list.setCellRenderer(new MagicCollectionIconListRenderer()); lstProviders = new JList<>(MTGControler.getInstance().listEnabled(MTGPricesProvider.class) .toArray(new MTGPricesProvider[MTGControler.getInstance().listEnabled(MTGPricesProvider.class).size()])); lstProviders.setCellRenderer(new PluginIconListRenderer()); panneaucentral.add(new JScrollPane(list), UITools.createGridBagConstraints(null, GridBagConstraints.BOTH, 0, 1)); panneaucentral.add(new JScrollPane(lstProviders), UITools.createGridBagConstraints(null, GridBagConstraints.BOTH, 1, 1)); btnGenerate.addActionListener(e -> { value = true; setVisible(false); }); setLocationRelativeTo(null); }
Example 9
Source File: FileChooserActionListener.java From kieker with Apache License 2.0 | 4 votes |
public static FileChooserActionListener createDirectoryChooserActionListener(final JTextComponent textComponent, final Component parent) { return new FileChooserActionListener(textComponent, JFileChooser.DIRECTORIES_ONLY, parent); }
Example 10
Source File: GenericDialogPlus.java From ij-ridgedetection with GNU General Public License v2.0 | 2 votes |
/** * Instantiates a new directory listener. * * @param title * the title * @param text * the text */ public DirectoryListener(String title, TextField text) { this(title, text, JFileChooser.DIRECTORIES_ONLY); }