List of usage examples for javax.swing JFileChooser setDialogTitle
@BeanProperty(preferred = true, description = "The title of the JFileChooser dialog window.") public void setDialogTitle(String dialogTitle)
JFileChooser
window's title bar. From source file:net.liuxuan.device.VACVBS.JIF_DrawChart_vacvbs.java
protected JFileChooser initFileChooser() { ExtensionFileFilter filter = new ExtensionFileFilter("log,txt", true, true); filter.setDescription("?"); JFileChooser jfc = new JFileChooser(); FileSystemView fsv = FileSystemView.getFileSystemView(); //?/*w w w . j a v a 2 s. c o m*/ jfc.setCurrentDirectory(fsv.getHomeDirectory()); jfc.setDialogTitle("?"); jfc.setMultiSelectionEnabled(false); jfc.setDialogType(JFileChooser.OPEN_DIALOG); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);//JFileChooser.FILES_AND_DIRECTORIES jfc.setFileFilter(filter); return jfc; }
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
private void menuNewProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuNewProjectActionPerformed final JFileChooser folder = new JFileChooser(); folder.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); folder.setDialogTitle("Create project folder"); folder.setApproveButtonText("Create"); folder.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (folder.showOpenDialog(Main.getApplicationFrame()) == JFileChooser.APPROVE_OPTION) { final File file = folder.getSelectedFile(); if (file.exists()) { DialogProviderManager.getInstance().getDialogProvider() .msgError("File '" + file.getName() + "' already exists!"); } else if (file.mkdirs()) { if (PreferencesManager.getInstance().getPreferences() .getBoolean(PreferencesPanel.PREFERENCE_KEY_KNOWLEDGEFOLDER_ALLOWED, true)) { final File knowledgeFolder = new File(file, ".projectKnowledge"); knowledgeFolder.mkdirs(); }//from w w w . ja v a 2 s . c om if (openProject(file, true)) { this.focusInTree(file); } } else { LOGGER.error("Can't create folder : " + file); DialogProviderManager.getInstance().getDialogProvider().msgError("Can't create folder: " + file); } } }
From source file:com._17od.upm.gui.DatabaseActions.java
public void openDatabase() throws IOException, ProblemReadingDatabaseFile, CryptoException { JFileChooser fc = new JFileChooser(); fc.setDialogTitle(Translator.translate("openDatabase")); int returnVal = fc.showOpenDialog(mainWindow); if (returnVal == JFileChooser.APPROVE_OPTION) { File databaseFile = fc.getSelectedFile(); if (databaseFile.exists()) { openDatabase(databaseFile.getAbsolutePath()); } else {//from w w w. ja va 2s .c o m JOptionPane.showMessageDialog(mainWindow, Translator.translate("fileDoesntExistWithName", databaseFile.getAbsolutePath()), Translator.translate("fileDoesntExist"), JOptionPane.ERROR_MESSAGE); } } // Stop any "SetDBDirtyThread"s that are running runSetDBDirtyThread = false; }
From source file:AltiConsole.AltiConsoleMainScreen.java
/** * Handles all the actions./* w ww . ja va 2 s . c om*/ * * @param e * the action event. */ public void actionPerformed(final ActionEvent e) { final Translator trans = Application.getTranslator(); if (e.getActionCommand().equals("EXIT")) { System.out.println("exit and disconnecting\n"); if (JOptionPane.showConfirmDialog(this, trans.get("AltiConsoleMainScreen.ClosingWindow"), trans.get("AltiConsoleMainScreen.ReallyClosing"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { DisconnectFromAlti(); System.exit(0); } } else if (e.getActionCommand().equals("ABOUT")) { AboutDialog.showPreferences(AltiConsoleMainScreen.this); } // ERASE_FLIGHT else if (e.getActionCommand().equals("ERASE_FLIGHT")) { if (JOptionPane.showConfirmDialog(this, trans.get("AltiConsoleMainScreen.eraseAllflightData"), trans.get("AltiConsoleMainScreen.eraseAllflightDataTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { System.out.println("erasing flight\n"); ErasingFlight(); } } else if (e.getActionCommand().equals("RETRIEVE_FLIGHT")) { System.out.println("retrieving flight\n"); RetrievingFlight(); } else // SAVE_FLIGHT if (e.getActionCommand().equals("SAVE_FLIGHT")) { System.out.println("Saving current flight\n"); SavingFlight(); } else // RETRIEVE_ALTI_CFG if (e.getActionCommand().equals("RETRIEVE_ALTI_CFG")) { System.out.println("retrieving alti config\n"); AltiConfigData pAlticonfig = retrieveAltiConfig(); if (pAlticonfig != null) AltiConfigDlg.showPreferences(AltiConsoleMainScreen.this, pAlticonfig, Serial); } // LICENSE else if (e.getActionCommand().equals("LICENSE")) { LicenseDialog.showPreferences(AltiConsoleMainScreen.this); } // comPorts else if (e.getActionCommand().equals("comPorts")) { DisconnectFromAlti(); String currentPort; //e. currentPort = (String) comPorts.getSelectedItem(); if (Serial != null) Serial.searchForPorts(); System.out.println("We have a new selected value for comport\n"); comPorts.setSelectedItem(currentPort); } // UPLOAD_FIRMWARE else if (e.getActionCommand().equals("UPLOAD_FIRMWARE")) { System.out.println("upload firmware\n"); //make sure to disconnect first DisconnectFromAlti(); JFileChooser fc = new JFileChooser(); String hexfile = null; File startFile = new File(System.getProperty("user.dir")); //FileNameExtensionFilter filter; fc.setDialogTitle("Select firmware"); //fc.set fc.setCurrentDirectory(startFile); //fc.addChoosableFileFilter(new FileNameExtensionFilter("*.HEX", "hex")); fc.setFileFilter(new FileNameExtensionFilter("*.hex", "hex")); //fc.fil int action = fc.showOpenDialog(SwingUtilities.windowForComponent(this)); if (action == JFileChooser.APPROVE_OPTION) { hexfile = fc.getSelectedFile().getAbsolutePath(); } if (hexfile != null) { String exefile = UserPref.getAvrdudePath(); String conffile = UserPref.getAvrdudeConfigPath(); String opts = " -v -v -v -v -patmega328p -carduino -P\\\\.\\" + (String) this.comPorts.getSelectedItem() + " -b115200 -D -V "; String cmd = exefile + " -C" + conffile + opts + " -Uflash:w:" + hexfile + ":i"; System.out.println(cmd); try { Process p = Runtime.getRuntime().exec(cmd); AfficheurFlux fluxSortie = new AfficheurFlux(p.getInputStream(), this); AfficheurFlux fluxErreur = new AfficheurFlux(p.getErrorStream(), this); new Thread(fluxSortie).start(); new Thread(fluxErreur).start(); p.waitFor(); } catch (IOException e1) { e1.printStackTrace(); } catch (InterruptedException e2) { e2.printStackTrace(); } } } // ON_LINE_HELP else if (e.getActionCommand().equals("ON_LINE_HELP")) { Desktop d = Desktop.getDesktop(); System.out.println("Online help \n"); try { d.browse(new URI(trans.get("help.url"))); } catch (URISyntaxException e1) { System.out.println("Illegal URL: " + trans.get("help.url") + " " + e1.getMessage()); } catch (IOException e1) { System.out.println("Unable to launch browser: " + e1.getMessage()); } } }
From source file:com._17od.upm.gui.DatabaseActions.java
/** * This method prompts the user for the name of a file. * If the file exists then it will ask if they want to overwrite (the file isn't overwritten though, * that would be done by the calling method) * @param title The string title to put on the dialog * @return The file to save to or null/*from www . ja va 2 s . c o m*/ */ private File getSaveAsFile(String title) { File selectedFile; boolean gotValidFile = false; do { JFileChooser fc = new JFileChooser(); fc.setDialogTitle(title); int returnVal = fc.showSaveDialog(mainWindow); if (returnVal != JFileChooser.APPROVE_OPTION) { return null; } selectedFile = fc.getSelectedFile(); //Warn the user if the database file already exists if (selectedFile.exists()) { Object[] options = { "Yes", "No" }; int i = JOptionPane.showOptionDialog(mainWindow, Translator.translate("fileAlreadyExistsWithFileName", selectedFile.getAbsolutePath()) + '\n' + Translator.translate("overwrite"), Translator.translate("fileAlreadyExists"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if (i == JOptionPane.YES_OPTION) { gotValidFile = true; } } else { gotValidFile = true; } } while (!gotValidFile); return selectedFile; }
From source file:de.juwimm.cms.content.panel.PanDocuments.java
private void upload(String prosa, Integer unit, Integer viewComponentId, Integer documentId) { this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JFileChooser fc = new JFileChooser(); int ff = fc.getChoosableFileFilters().length; FileFilter[] fft = fc.getChoosableFileFilters(); for (int i = 0; i < ff; i++) { fc.removeChoosableFileFilter(fft[i]); }/* www .j a v a2 s .c o m*/ fc.addChoosableFileFilter(new DocumentFilter()); fc.setAccessory(new ImagePreview(fc)); fc.setDialogTitle(prosa); fc.setMultiSelectionEnabled(true); fc.setCurrentDirectory(Constants.LAST_LOCAL_UPLOAD_DIR); int returnVal = fc.showDialog(this, Messages.getString("panel.content.documents.addDocument")); if (returnVal == JFileChooser.APPROVE_OPTION) { File[] files = fc.getSelectedFiles(); uploadFiles(files, unit, viewComponentId, documentId); Constants.LAST_LOCAL_UPLOAD_DIR = fc.getCurrentDirectory(); } this.setCursor(Cursor.getDefaultCursor()); }
From source file:com._17od.upm.gui.DatabaseActions.java
public void importAccounts() throws TransportException, ProblemReadingDatabaseFile, IOException, CryptoException, PasswordDatabaseException { if (getLatestVersionOfDatabase()) { // Prompt for the file to import JFileChooser fc = new JFileChooser(); fc.setDialogTitle(Translator.translate("import")); int returnVal = fc.showOpenDialog(mainWindow); if (returnVal == JFileChooser.APPROVE_OPTION) { File csvFile = fc.getSelectedFile(); // Unmarshall the accounts from the CSV file try { AccountsCSVMarshaller marshaller = new AccountsCSVMarshaller(); ArrayList accountsInCSVFile = marshaller.unmarshal(csvFile); ArrayList accountsToImport = new ArrayList(); boolean importCancelled = false; // Add each account to the open database. If the account // already exits the prompt to overwrite for (int i = 0; i < accountsInCSVFile.size(); i++) { AccountInformation importedAccount = (AccountInformation) accountsInCSVFile.get(i); if (database.getAccount(importedAccount.getAccountName()) != null) { Object[] options = { "Overwrite Existing", "Keep Existing", "Cancel" }; int answer = JOptionPane.showOptionDialog(mainWindow, Translator.translate("importExistingQuestion", importedAccount.getAccountName()), Translator.translate("importExistingTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if (answer == 1) { continue; // If keep existing then continue to the next iteration } else if (answer == 2) { importCancelled = true; break; // Cancel the import }/*from ww w. j a va 2 s . c o m*/ } accountsToImport.add(importedAccount); } if (!importCancelled && accountsToImport.size() > 0) { for (int i = 0; i < accountsToImport.size(); i++) { AccountInformation accountToImport = (AccountInformation) accountsToImport.get(i); database.deleteAccount(accountToImport.getAccountName()); database.addAccount(accountToImport); } saveDatabase(); accountNames = getAccountNames(); filter(); } } catch (ImportException e) { JOptionPane.showMessageDialog(mainWindow, e.getMessage(), Translator.translate("problemImporting"), JOptionPane.ERROR_MESSAGE); } catch (IOException e) { JOptionPane.showMessageDialog(mainWindow, e.getMessage(), Translator.translate("problemImporting"), JOptionPane.ERROR_MESSAGE); } catch (CryptoException e) { JOptionPane.showMessageDialog(mainWindow, e.getMessage(), Translator.translate("problemImporting"), JOptionPane.ERROR_MESSAGE); } } } }
From source file:org.pgptool.gui.ui.decryptone.DecryptOnePm.java
public ExistingFileChooserDialog getSourceFileChooser() { if (sourceFileChooser == null) { sourceFileChooser = new ExistingFileChooserDialog(findRegisteredWindowIfAny(), appProps, SOURCE_FOLDER) {// w w w . j a va 2s. c o m @Override protected void doFileChooserPostConstruct(JFileChooser ofd) { super.doFileChooserPostConstruct(ofd); ofd.setAcceptAllFileFilterUsed(false); ofd.addChoosableFileFilter( new FileNameExtensionFilter("Encrypted files (.gpg, .pgp, .asc)", EXTENSIONS)); ofd.addChoosableFileFilter(ofd.getAcceptAllFileFilter()); ofd.setFileFilter(ofd.getChoosableFileFilters()[0]); ofd.setDialogTitle(text("phrase.selectFileToDecrypt")); } @Override protected String handleFileWasChosen(String filePathName) { if (filePathName == null) { return null; } sourceFile.setValueByOwner(filePathName); return filePathName; } }; } return sourceFileChooser; }
From source file:gdt.jgui.entity.folder.JFolderPanel.java
/** * Get the context menu./*from ww w .java 2s .c om*/ * @return the context menu. */ @Override public JMenu getContextMenu() { menu = super.getContextMenu(); mia = null; int cnt = menu.getItemCount(); if (cnt > 0) { mia = new JMenuItem[cnt]; for (int i = 0; i < cnt; i++) mia[i] = menu.getItem(i); } menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { //System.out.println("EntitiesPanel:getConextMenu:menu selected"); menu.removeAll(); if (mia != null) { for (JMenuItem mi : mia) menu.add(mi); menu.addSeparator(); } JMenuItem refreshItem = new JMenuItem("Refresh"); refreshItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JConsoleHandler.execute(console, locator$); } }); menu.add(refreshItem); JMenuItem openItem = new JMenuItem("Open folder"); openItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { File folder = new File(entihome$ + "/" + entityKey$); if (!folder.exists()) folder.mkdir(); Desktop.getDesktop().open(folder); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); menu.add(openItem); JMenuItem importItem = new JMenuItem("Import"); importItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { File home = new File(System.getProperty("user.home")); Desktop.getDesktop().open(home); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); menu.add(importItem); JMenuItem newItem = new JMenuItem("New text"); newItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JTextEditor textEditor = new JTextEditor(); String teLocator$ = textEditor.getLocator(); teLocator$ = Locator.append(teLocator$, Entigrator.ENTIHOME, entihome$); String text$ = "New" + Identity.key().substring(0, 4) + ".txt"; teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, text$); JFolderPanel fp = new JFolderPanel(); String fpLocator$ = fp.getLocator(); fpLocator$ = Locator.append(fpLocator$, Entigrator.ENTIHOME, entihome$); fpLocator$ = Locator.append(fpLocator$, EntityHandler.ENTITY_KEY, entityKey$); fpLocator$ = Locator.append(fpLocator$, BaseHandler.HANDLER_METHOD, "response"); fpLocator$ = Locator.append(fpLocator$, JRequester.REQUESTER_ACTION, ACTION_CREATE_FILE); String requesterResponseLocator$ = Locator.compressText(fpLocator$); teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, requesterResponseLocator$); JConsoleHandler.execute(console, teLocator$); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); menu.add(newItem); //menu.addSeparator(); if (hasToInsert()) { menu.addSeparator(); JMenuItem insertItem = new JMenuItem("Insert"); insertItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable clipboardContents = systemClipboard.getContents(null); if (clipboardContents == null) return; Object transferData = clipboardContents .getTransferData(DataFlavor.javaFileListFlavor); List<File> files = (List<File>) transferData; for (int i = 0; i < files.size(); i++) { File file = (File) files.get(i); if (file.exists() && file.isFile()) { System.out.println("FolderPanel:insert:in=" + file.getPath()); File dir = new File(entihome$ + "/" + entityKey$); if (!dir.exists()) dir.mkdir(); File out = new File(entihome$ + "/" + entityKey$ + "/" + file.getName()); if (!out.exists()) out.createNewFile(); System.out.println("FolderPanel:insert:out=" + out.getPath()); FileExpert.copyFile(file, out); JConsoleHandler.execute(console, getLocator()); } // System.out.println("FolderPanel:import:file="+file.getPath()); } } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); menu.add(insertItem); } if (hasToPaste()) { menu.addSeparator(); JMenuItem pasteItem = new JMenuItem("Paste"); pasteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String[] sa = console.clipboard.getContent(); Properties locator; String file$; File file; File target; String dir$ = entihome$ + "/" + entityKey$; File dir = new File(dir$); if (!dir.exists()) dir.mkdir(); for (String aSa : sa) { try { locator = Locator.toProperties(aSa); if (LOCATOR_TYPE_FILE.equals(locator.getProperty(Locator.LOCATOR_TYPE))) { file$ = locator.getProperty(FILE_PATH); file = new File(file$); target = new File(dir$ + "/" + file.getName()); if (!target.exists()) target.createNewFile(); FileExpert.copyFile(file, target); } } catch (Exception ee) { LOGGER.info(ee.toString()); } } JConsoleHandler.execute(console, locator$); } }); menu.add(pasteItem); } if (hasSelectedItems()) { menu.addSeparator(); JMenuItem deleteItem = new JMenuItem("Delete"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { String[] sa = JFolderPanel.this.listSelectedItems(); if (sa == null) return; Properties locator; String file$; File file; for (String aSa : sa) { locator = Locator.toProperties(aSa); file$ = locator.getProperty(FILE_PATH); file = new File(file$); try { if (file.isDirectory()) FileExpert.clear(file$); file.delete(); } catch (Exception ee) { LOGGER.info(ee.toString()); } } } JConsoleHandler.execute(console, locator$); } }); menu.add(deleteItem); JMenuItem copyItem = new JMenuItem("Copy"); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String[] sa = JFolderPanel.this.listSelectedItems(); console.clipboard.clear(); if (sa != null) for (String aSa : sa) console.clipboard.putString(aSa); } }); menu.add(copyItem); JMenuItem exportItem = new JMenuItem("Export"); exportItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { String[] sa = JFolderPanel.this.listSelectedItems(); Properties locator; String file$; File file; ArrayList<File> fileList = new ArrayList<File>(); for (String aSa : sa) { try { locator = Locator.toProperties(aSa); file$ = locator.getProperty(FILE_PATH); file = new File(file$); fileList.add(file); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } File[] fa = fileList.toArray(new File[0]); if (fa.length < 1) return; // System.out.println("Folderpanel:finish:list="+fa.length); JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(System.getProperty("user.home"))); chooser.setDialogTitle("Export files"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showSaveDialog(JFolderPanel.this) == JFileChooser.APPROVE_OPTION) { String dir$ = chooser.getSelectedFile().getPath(); File target; for (File f : fa) { target = new File(dir$ + "/" + f.getName()); if (!target.exists()) target.createNewFile(); FileExpert.copyFile(f, target); } } else { Logger.getLogger(JMainConsole.class.getName()).info(" no selection"); } // System.out.println("Folderpanel:finish:list="+fileList.size()); } catch (Exception eee) { LOGGER.severe(eee.toString()); } } }); menu.add(exportItem); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu; }
From source file:ffx.ui.KeywordPanel.java
/** * <p>//from ww w . j av a 2 s.c o m * keySaveAs</p> */ public void keySaveAs() { if (!fileOpen) { return; } JFileChooser d = MainPanel.resetFileChooser(); d.setDialogTitle("Save KEY File"); d.setAcceptAllFileFilterUsed(false); if (currentKeyFile != null) { d.setCurrentDirectory(currentKeyFile.getParentFile()); d.setSelectedFile(currentKeyFile); } d.setFileFilter(new KeyFileFilter()); int result = d.showSaveDialog(this); if (result == JFileChooser.APPROVE_OPTION) { currentKeyFile = d.getSelectedFile(); keySave(currentKeyFile); } }