List of usage examples for javax.swing JFileChooser FILES_ONLY
int FILES_ONLY
To view the source code for javax.swing JFileChooser FILES_ONLY.
Click Source Link
From source file:se.trixon.almond.dialogs.SimpleDialog.java
public static boolean openFile(boolean multiSelection) { sFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); sFileChooser.setMultiSelectionEnabled(multiSelection); sPaths = new File[0]; int result = sFileChooser.showOpenDialog(sParent); if (result == JFileChooser.APPROVE_OPTION) { if (multiSelection) { sPaths = sFileChooser.getSelectedFiles(); } else {//from w ww . ja v a 2 s.c o m sPath = sFileChooser.getSelectedFile(); } } return result == JFileChooser.APPROVE_OPTION; }
From source file:se.trixon.toolbox.idiot.task.TaskPanel.java
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */// w ww. j ava 2 s . co m @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { activeCheckBox = new javax.swing.JCheckBox(); nameLabel = new javax.swing.JLabel(); nameTextField = new javax.swing.JTextField(); descriptionLabel = new javax.swing.JLabel(); descriptionTextField = new javax.swing.JTextField(); urlLabel = new javax.swing.JLabel(); urlTextField = new javax.swing.JTextField(); destinationPanel = new se.trixon.almond.util.swing.dialogs.FileChooserPanel(); org.openide.awt.Mnemonics.setLocalizedText(activeCheckBox, Dict.ACTIVE.getString()); org.openide.awt.Mnemonics.setLocalizedText(nameLabel, Dict.NAME.getString()); org.openide.awt.Mnemonics.setLocalizedText(descriptionLabel, Dict.DESCRIPTION.getString()); org.openide.awt.Mnemonics.setLocalizedText(urlLabel, "URL"); // NOI18N urlTextField.setText(org.openide.util.NbBundle.getMessage(TaskPanel.class, "TaskPanel.urlTextField.text")); // NOI18N destinationPanel.setHeader(Dict.DESTINATION.getString()); destinationPanel.setMode(JFileChooser.FILES_ONLY); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(nameTextField).addComponent(descriptionTextField) .addComponent(destinationPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE) .addComponent(urlTextField) .addGroup(layout .createSequentialGroup() .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(nameLabel).addComponent(descriptionLabel) .addComponent(urlLabel).addComponent(activeCheckBox)) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(nameLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(descriptionLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(descriptionTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(urlLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(urlTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(destinationPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(activeCheckBox) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); }
From source file:tvbrowser.ui.settings.WebbrowserSettingsTab.java
/** * Creates the settings panel for this tab. *///from ww w. j a va2 s . com public JPanel createSettingsPanel() { mSettingsPn = new JPanel(new FormLayout("5dlu, 10dlu, pref, 3dlu, pref, 3dlu, pref, fill:3dlu:grow, 3dlu", "pref, 5dlu, pref, 5dlu, pref, 5dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref")); mSettingsPn.setBorder(Borders.DIALOG_BORDER); CellConstraints cc = new CellConstraints(); mSettingsPn.add( DefaultComponentFactory.getInstance().createSeparator(mLocalizer.msg("browser", "Web browser")), cc.xyw(1, 1, 9)); JButton testButton = new LinkButton(mLocalizer.msg("testBrowser", "Test Webbrowser"), "http://www.tvbrowser.org", SwingConstants.LEFT, false); testButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String buffer = Settings.propUserDefinedWebbrowser.getString(); String bufferParams = Settings.propUserDefinedWebbrowserParams.getString(); saveSettings(); Launch.openURL("http://www.tvbrowser.org"); Settings.propUserDefinedWebbrowser.setString(buffer); Settings.propUserDefinedWebbrowserParams.setString(bufferParams); } }); mSettingsPn.add(UiUtilities.createHelpTextArea(mLocalizer.msg("help", "Help Text")), cc.xyw(2, 3, 7)); mSettingsPn.add(testButton, cc.xyw(2, 5, 7)); mSettingsPn.add(new JLabel(mLocalizer.msg("whichBrowser", "which browser")), cc.xyw(2, 7, 7)); JRadioButton useDefault = new JRadioButton(mLocalizer.msg("defaultWebbrowser", "Default Webbrowser")); useDefault.setSelected(Settings.propUserDefinedWebbrowser.getString() == null); useDefault.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateInputFields(); } }); mSettingsPn.add(useDefault, cc.xyw(2, 9, 4)); mUseWebbrowser = new JRadioButton(mLocalizer.msg("userDefinedWebbrowser", "user defined webbrowser")); mUseWebbrowser.setSelected(Settings.propUserDefinedWebbrowser.getString() != null); mUseWebbrowser.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateInputFields(); } }); ButtonGroup group = new ButtonGroup(); group.add(useDefault); group.add(mUseWebbrowser); mSettingsPn.add(mUseWebbrowser, cc.xyw(2, 11, 7)); mSettingsPn.add(new JLabel(mLocalizer.msg("browserExecutable", "Executable") + ":"), cc.xy(3, 13)); mFileTextField = new JTextField(30); mFileTextField.setText(Settings.propUserDefinedWebbrowser.getString()); mSettingsPn.add(mFileTextField, cc.xy(5, 13)); mChooseButton = new JButton(Localizer.getLocalization(Localizer.I18N_SELECT)); mChooseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { if (mFileChooser == null) { mFileChooser = new JFileChooser(); if (OperatingSystem.isMacOs()) { mFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); } else { mFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); } } int retVal = mFileChooser.showOpenDialog(mSettingsPn.getParent()); if (retVal == JFileChooser.APPROVE_OPTION) { File f = mFileChooser.getSelectedFile(); if (f != null) { mFileTextField.setText(f.getAbsolutePath()); } } } }); mSettingsPn.add(mChooseButton, cc.xy(7, 13)); mSettingsPn.add(new JLabel(mLocalizer.msg("browserParameter", "Parameter") + ":"), cc.xy(3, 15)); mParams = new JTextField(); mParams.setText(Settings.propUserDefinedWebbrowserParams.getString()); mSettingsPn.add(mParams, cc.xy(5, 15)); mSettingsPn.add(new JLabel(mLocalizer.msg("browserParameterHelp", "{0} will be replaced by the url.")), cc.xyw(5, 17, 4)); updateInputFields(); return mSettingsPn; }
From source file:uk.sipperfly.ui.Exactly.java
private void importXmlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importXmlActionPerformed fileChooser = new javax.swing.JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);//FILES_AND_DIRECTORIES int returnVal = fileChooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); if (file.getName().indexOf("xml") > 0) { UpdateResult("Importing xml.", 0); // inputDirPath = file.getAbsolutePath(); String message = this.uIManager.importXml(file.getAbsolutePath().toString()); if (!message.equalsIgnoreCase("Invalid xml format")) { this.currentTemplate.setText("Current Template: ".concat(file.getName())); this.clearTempButton.setVisible(true); }/*from w w w . j ava2 s .c o m*/ UpdateResult(message, 0); } else { UpdateResult("Select xml file.", 0); } } }
From source file:us.daveread.basicquery.BasicQuery.java
/** * Open or create a SQL statement file.// ww w . j av a 2 s . c o m */ private void openSQLFile() { JFileChooser fileMenu; FileFilter defaultFileFilter = null; FileFilter preferredFileFilter = null; File chosenSQLFile; int returnVal; chosenSQLFile = null; // Save current information, including SQL Statements saveConfig(); // Allow user to choose/create new file for SQL Statements fileMenu = new JFileChooser(new File(queryFilename)); for (FileFilterDefinition filterDefinition : FileFilterDefinition.values()) { if (filterDefinition.name().startsWith("QUERY")) { final FileFilter fileFilter = new SuffixFileFilter(filterDefinition.description(), filterDefinition.acceptedSuffixes()); if (filterDefinition.isPreferredOption()) { preferredFileFilter = fileFilter; } fileMenu.addChoosableFileFilter(fileFilter); if (filterDefinition.description().equals(latestChosenQueryFileFilterDescription)) { defaultFileFilter = fileFilter; } } } if (defaultFileFilter != null) { fileMenu.setFileFilter(defaultFileFilter); } else if (latestChosenQueryFileFilterDescription != null && latestChosenQueryFileFilterDescription.startsWith("All")) { fileMenu.setFileFilter(fileMenu.getAcceptAllFileFilter()); } else if (preferredFileFilter != null) { fileMenu.setFileFilter(preferredFileFilter); } fileMenu.setSelectedFile(new File(queryFilename)); fileMenu.setDialogTitle(Resources.getString("dlgSQLFileTitle")); fileMenu.setDialogType(JFileChooser.OPEN_DIALOG); fileMenu.setFileSelectionMode(JFileChooser.FILES_ONLY); fileMenu.setMultiSelectionEnabled(false); if (fileMenu.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { chosenSQLFile = fileMenu.getSelectedFile(); // Adjust file suffix if necessary final FileFilter fileFilter = fileMenu.getFileFilter(); if (fileFilter != null && fileFilter instanceof SuffixFileFilter && !fileMenu.getFileFilter().accept(chosenSQLFile)) { chosenSQLFile = ((SuffixFileFilter) fileFilter).makeWithPrimarySuffix(chosenSQLFile); } if (!chosenSQLFile.exists()) { returnVal = JOptionPane.showConfirmDialog(this, Resources.getString("dlgNewSQLFileText", chosenSQLFile.getName()), Resources.getString("dlgNewSQLFileTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.NO_OPTION) { querySelection.removeAllItems(); queryText.setText(""); QueryHistory.getInstance().clearAllQueries(); // Update GUI setPrevNextIndication(); } else if (returnVal == JOptionPane.CANCEL_OPTION) { chosenSQLFile = null; } } else { setQueryFilename(chosenSQLFile.getAbsolutePath()); querySelection.removeAllItems(); queryText.setText(""); loadCombo(querySelection, queryFilename); QueryHistory.getInstance().clearAllQueries(); // Update GUI setPrevNextIndication(); } } try { latestChosenQueryFileFilterDescription = fileMenu.getFileFilter().getDescription(); } catch (Throwable throwable) { LOGGER.warn("Unable to determine which ontology file filter was chosen", throwable); } if (chosenSQLFile != null) { setQueryFilename(chosenSQLFile.getAbsolutePath()); saveConfig(); } }
From source file:View.Main.java
private void jButton_loadImageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_loadImageActionPerformed // TODO add your handling code here: jLabel_status.setText(" "); JFileChooser fc = new JFileChooser(); Double rating;//from w ww .jav a 2s . c om fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.addChoosableFileFilter(new FileNameExtensionFilter("JPEG files", "jpeg", "jpg")); fc.addChoosableFileFilter(new FileNameExtensionFilter("PNG files", "png", "PNG")); fc.addChoosableFileFilter(new FileNameExtensionFilter("BMP files", "bmp", "BMP")); fc.setAcceptAllFileFilterUsed(true); int returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { imagePath = fc.getSelectedFile().getAbsolutePath(); rating = imageAnalizer.getRating(imagePath); setTextRating(rating); populateProgressBar(rating); try { setImage(imagePath); } catch (IOException ex) { JOptionPane.showMessageDialog(null, "Please select an image of valid format", "Error", JOptionPane.WARNING_MESSAGE); //Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } getNews(rating); } // else { // JOptionPane.showMessageDialog(null, "Please select an image of valid format", "Error", JOptionPane.WARNING_MESSAGE); // } }
From source file:wqm.util.ProcessDataGUI.java
public static void main(String[] args) throws IOException, ParseException { JFileChooser fc = new JFileChooser(); fc.setDialogTitle("Select data file."); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setMultiSelectionEnabled(true);/*www. j a v a 2 s .c o m*/ int returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File[] files = fc.getSelectedFiles(); fc.setDialogTitle("Select output location."); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setMultiSelectionEnabled(false); returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File outputDirectory = fc.getSelectedFile(); for (File inputFile : files) { ProcessData .main(new String[] { inputFile.getAbsolutePath(), outputDirectory.getAbsolutePath() }); } } } }