Java Code Examples for javax.swing.JFileChooser#setControlButtonsAreShown()
The following examples show how to use
javax.swing.JFileChooser#setControlButtonsAreShown() .
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: Utils.java From j-j-jvm with Apache License 2.0 | 6 votes |
public static File selectFileForSave(final Component parent, final FileFilter fileFiltere, final String title, final File initFile) { final JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); chooser.setDragEnabled(false); chooser.setControlButtonsAreShown(true); chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setFileFilter(fileFiltere); chooser.setDialogTitle(title); chooser.setAcceptAllFileFilterUsed(false); if (initFile != null) { chooser.setSelectedFile(initFile); } if (chooser.showDialog(parent, "Save") == JFileChooser.APPROVE_OPTION) { final File file = chooser.getSelectedFile(); return file; } else { return null; } }
Example 2
Source File: FileChooserBuilder.java From netbeans with Apache License 2.0 | 5 votes |
private void prepareFileChooser(JFileChooser chooser) { chooser.setFileSelectionMode(dirsOnly ? JFileChooser.DIRECTORIES_ONLY : filesOnly ? JFileChooser.FILES_ONLY : JFileChooser.FILES_AND_DIRECTORIES); chooser.setFileHidingEnabled(fileHiding); chooser.setControlButtonsAreShown(controlButtonsShown); chooser.setAcceptAllFileFilterUsed(useAcceptAllFileFilter); if (title != null) { chooser.setDialogTitle(title); } if (approveText != null) { chooser.setApproveButtonText(approveText); } if (badger != null) { chooser.setFileView(new CustomFileView(new BadgeIconProvider(badger), chooser.getFileSystemView())); } if (PREVENT_SYMLINK_TRAVERSAL) { FileUtil.preventFileChooserSymlinkTraversal(chooser, chooser.getCurrentDirectory()); } if (filter != null) { chooser.setFileFilter(filter); } if (aDescription != null) { chooser.getAccessibleContext().setAccessibleDescription(aDescription); } if (!filters.isEmpty()) { for (FileFilter f : filters) { chooser.addChoosableFileFilter(f); } } }
Example 3
Source File: LoadDialog.java From freecol with GNU General Public License v2.0 | 5 votes |
/** * Creates a dialog to choose a file to load. * * @param freeColClient The {@code FreeColClient} for the game. * @param frame The owner frame. * @param directory The directory to display when choosing the file. * @param fileFilters The available file filters in the dialog. */ public LoadDialog(FreeColClient freeColClient, JFrame frame, File directory, FileFilter[] fileFilters) { super(freeColClient, frame); final JFileChooser fileChooser = new JFileChooser(directory); if (fileFilters.length > 0) { for (FileFilter fileFilter : fileFilters) { fileChooser.addChoosableFileFilter(fileFilter); } fileChooser.setFileFilter(fileFilters[0]); fileChooser.setAcceptAllFileFilterUsed(false); } fileChooser.setControlButtonsAreShown(true); fileChooser.setApproveButtonText(Messages.message("ok")); //fileChooser.setCancelButtonText(Messages.message("cancel")); fileChooser.setDialogType(JFileChooser.OPEN_DIALOG); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setFileHidingEnabled(false); fileChooser.addActionListener((ActionEvent ae) -> { final String cmd = ae.getActionCommand(); File value = (JFileChooser.APPROVE_SELECTION.equals(cmd)) ? ((JFileChooser)ae.getSource()).getSelectedFile() : cancelFile; setValue(value); }); List<ChoiceItem<File>> c = choices(); initializeDialog(frame, DialogType.QUESTION, true, fileChooser, null, c); }
Example 4
Source File: ShareToolBuilder.java From raccoon4 with Apache License 2.0 | 5 votes |
@Override protected JPanel assemble() { JPanel ret = new JPanel(); TitleStrip titleStrip = new TitleStrip(Messages.getString(ID + ".title"), Messages.getString(ID + ".subtitle"), new ImageIcon(getClass() .getResource("/icons/appicon.png"))); transfer = new QrPanel(300); transfer.withActions(new CopyContentAction(globals, transfer)); transfer.setBorder(new TitledBorder(Messages.getString(ID + ".transfer"))); chooser = new JFileChooser(globals.get(Layout.class).shareDir); chooser.setMultiSelectionEnabled(true); chooser.setControlButtonsAreShown(false); chooser.addPropertyChangeListener(this); ret.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 2; gbc.weightx = 1; gbc.weighty = 1; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.NORTHWEST; ret.add(titleStrip, gbc); gbc.gridy = 1; gbc.gridwidth = 1; gbc.fill = GridBagConstraints.NONE; ret.add(chooser, gbc); gbc.gridx = 1; gbc.insets = new Insets(7, 7, 7, 7); ret.add(transfer, gbc); return ret; }
Example 5
Source File: Utils.java From j-j-jvm with Apache License 2.0 | 5 votes |
public static File selectFileForOpen(final Component parent, final FileFilter[] fileFilters, final String title, final FileFilter[] selectedFilters, final File initFile) { JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); chooser.setDragEnabled(false); chooser.setControlButtonsAreShown(true); chooser.setDialogType(JFileChooser.OPEN_DIALOG); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); for (final FileFilter fileFilter : fileFilters) { chooser.addChoosableFileFilter(fileFilter); } chooser.setDialogTitle(title); chooser.setAcceptAllFileFilterUsed(false); if (initFile != null) { chooser.setCurrentDirectory(initFile); chooser.setName(initFile.getName()); } int returnVal = chooser.showDialog(parent, "Open"); selectedFilters[0] = chooser.getFileFilter(); if (returnVal == JFileChooser.APPROVE_OPTION) { File p_file = chooser.getSelectedFile(); return p_file; } else { return null; } }
Example 6
Source File: CPSGlobalSettings.java From cropplanning with GNU General Public License v3.0 | 5 votes |
public OutDirWizardPage () { super( PAGE_OUT_DIR, getDescription(), CPSWizardPage.WIZ_TYPE_PRE_INIT ); setLongDescription( getDescription() ); setPreferredSize( panelDim ); setMaximumSize( panelDim ); JLabel lblOutDir = new JLabel( "<html><body style='width: 300px'>" + "<b>Select a folder or directory to store all of your crop planning data.</b>" + "<p><p>If you have already used this program to create crop plans and would like to load that information, " + "please select the folder or directory which contains your existing data. " + "(The data files have names that start with \"CPSdb\".)" + "" ); lblOutDir.setAlignmentX( Component.CENTER_ALIGNMENT ); String defaultDirectory = CPSGlobalSettings.getOutputDir(); flchOutDir = new JFileChooser(); flchOutDir.setSelectedFile( new File( defaultDirectory ) ); flchOutDir.setName( SETTING_OUT_DIR ); flchOutDir.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY ); flchOutDir.setMultiSelectionEnabled( false ); flchOutDir.setControlButtonsAreShown( false ); flchOutDir.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange ( PropertyChangeEvent evt ) { if ( evt.getPropertyName().equals( JFileChooser.SELECTED_FILE_CHANGED_PROPERTY ) ) { outDirIsSelected = ( evt.getNewValue() != null ) ? true : false; userInputReceived( flchOutDir, evt ); } } } ); // new PropChangeListener flchOutDir.setPreferredSize( fileDim ); flchOutDir.setMaximumSize( fileDim ); add( lblOutDir ); add( flchOutDir ); }
Example 7
Source File: NewJFrame.java From cloudExplorer with GNU General Public License v3.0 | 4 votes |
private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed try { if (active_bucket > 0) { final JFrame bg_frame = new JFrame("Directory to Sync:"); final JFileChooser bg_choose = new JFileChooser(); bg_choose.setControlButtonsAreShown(false); bg_choose.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); final JButton bg_button = new JButton("Save"); bg_button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { File choice = new File(bg_choose.getSelectedFile().toString()); try { FileWriter fr = new FileWriter(Home + File.separator + "s3config.sync"); BufferedWriter bfr = new BufferedWriter(fr); bfr.write(cred.getAccess_key() + "@" + cred.getSecret_key() + "@" + cred.getEndpoint() + "@" + bg_choose.getSelectedFile().toString() + "@" + bucket_item[active_bucket].getText()); bfr.close(); } catch (Exception writeConfig) { jTextArea1.append("\n" + writeConfig.getMessage()); } jPanel9.setVisible(true); jTextArea1.append("\nWritten config: " + Home + File.separator + "s3config.sync"); calibrateTextArea(); bg_frame.setVisible(false); } }); JPanel bg_panel = new JPanel(); bg_frame.setResizable(false); bg_panel.setLayout(new BoxLayout(bg_panel, BoxLayout.PAGE_AXIS)); bg_panel.add(bg_choose); bg_frame.add(bg_panel); bg_panel.add(bg_button); bg_frame.setLocation(500, 500); bg_frame.pack(); bg_frame.setVisible(true); } else { jTextArea1.append("\nError: No bucket has been selected"); } } catch (Exception Download) { jTextArea1.append("\n" + Download.getMessage()); } }