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:InterfaceModule.JRobert.java
private void exportToFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportToFileActionPerformed JFileChooser chooser = new JFileChooser(System.getProperty("user.dir") + "/saves/"); chooser.setDialogTitle("Salve o relatrio"); File fileToSave;//from w ww . j a v a2 s . c om int selection = chooser.showSaveDialog(this); if (selection == JFileChooser.APPROVE_OPTION) fileToSave = chooser.getSelectedFile(); else return; try { FileWriter fr = new FileWriter(fileToSave); BufferedWriter bw = new BufferedWriter(fr); String[] text = jTextArea1.getText().split("\n"); for (String s : text) { bw.write(s); bw.newLine(); } bw.close(); fr.close(); } catch (IOException e) { } }
From source file:colectordedatos.resultados.java
private void Exportar_a_ExcelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Exportar_a_ExcelActionPerformed if (jTable1.getRowCount() > 0) { JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("Archivos de excel", "xls"); chooser.setFileFilter(filter);/*ww w.j ava 2s . c o m*/ chooser.setDialogTitle("Guardar archivo"); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { List<JTable> tb = new ArrayList<JTable>(); List<String> nom = new ArrayList<String>(); tb.add(jTable1); nom.add("Reporte de Errores"); String file = chooser.getSelectedFile().toString().concat(".xls"); try { exportaraexcel e = new exportaraexcel(new File(file), tb, nom); if (e.export()) { JOptionPane.showMessageDialog(null, "Los datos fueron exportados a excel en el directorio seleccionado", "Mensaje de Informacion", JOptionPane.INFORMATION_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(null, "Hubo un error " + e.getMessage(), " Error", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(this, "No hay datos para exportar", "Mensaje de error", JOptionPane.ERROR_MESSAGE); } }
From source file:com.adito.upgrade.GUIUpgrader.java
public GUIUpgrader() { super(new BorderLayout()); JPanel info = new JPanel(new BorderLayout(2, 2)); // info.setBackground(Color.white); // info.setForeground(Color.black); // info.setOpaque(true); info.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); JLabel l = new JLabel("<html><p>This utility upgrades configuration from " + "one version 0.1.16 installation to another " + "0.2.5+ installation. You may choose which resources you " + "wish to be copied. If resources with the same name already " + "exist they will be left as is."); l.setIcon(new ImageIcon(GUIUpgrader.class.getResource("upgrader-48x48.png"))); info.add(l, BorderLayout.CENTER); info.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH); mainPanel = new JPanel(new BorderLayout()); add(info, BorderLayout.NORTH); add(mainPanel, BorderLayout.CENTER); // Installations panel JPanel installations = new JPanel(new GridBagLayout()); installations.setBorder(BorderFactory.createTitledBorder("Installations")); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(2, 2, 2, 2); gbc.weightx = 2.0;// w w w .j a v a2 s . c o m UIUtil.jGridBagAdd(installations, new JLabel("Source"), gbc, GridBagConstraints.REMAINDER); gbc.weightx = 1.0; source = new JTextField(); source.getDocument().addDocumentListener(this); UIUtil.jGridBagAdd(installations, source, gbc, GridBagConstraints.RELATIVE); browseSource = new JButton("Browse"); browseSource.setMnemonic('b'); browseSource.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(source.getText()); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Select source installation directory (0.16.1)"); if (chooser.showOpenDialog(GUIUpgrader.this) == JFileChooser.APPROVE_OPTION) { source.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); gbc.weightx = 0.0; UIUtil.jGridBagAdd(installations, browseSource, gbc, GridBagConstraints.REMAINDER); gbc.weightx = 2.0; UIUtil.jGridBagAdd(installations, new JLabel("Target"), gbc, GridBagConstraints.REMAINDER); gbc.weightx = 1.0; target = new JTextField(System.getProperty("user.dir")); target.getDocument().addDocumentListener(this); UIUtil.jGridBagAdd(installations, target, gbc, GridBagConstraints.RELATIVE); browseTarget = new JButton("Browse"); browseTarget.setMnemonic('r'); browseTarget.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(target.getText()); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Select target installation directory (0.2.5+)"); if (chooser.showOpenDialog(GUIUpgrader.this) == JFileChooser.APPROVE_OPTION) { target.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); gbc.weightx = 0.0; UIUtil.jGridBagAdd(installations, browseTarget, gbc, GridBagConstraints.REMAINDER); mainPanel.add(installations, BorderLayout.NORTH); // Upgrade selection upgradeSelectionPanel = new JPanel(); upgradeSelectionPanel.setBorder(BorderFactory.createTitledBorder("Upgrades")); upgradeSelectionPanel.setLayout(new BoxLayout(upgradeSelectionPanel, BoxLayout.Y_AXIS)); mainPanel.add(upgradeSelectionPanel, BorderLayout.CENTER); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDoseResponseController.java
/** * Ask user to choose for a directory and invoke swing worker for creating * PDF report/*from w w w . j av a 2 s . c om*/ * * @throws IOException */ protected void createPdfReport() throws IOException { Experiment experiment = areaMainController.getExperiment(); // choose directory to save pdf file JFileChooser chooseDirectory = new JFileChooser(); chooseDirectory.setDialogTitle("Choose a directory to save the report"); chooseDirectory.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooseDirectory.setSelectedFile(new File("Dose Response Report " + experiment.toString() + " - " + experiment.getProject().toString() + ".pdf")); // in response to the button click, show open dialog int returnVal = chooseDirectory.showSaveDialog(areaMainController.getDataAnalysisPanel()); if (returnVal == JFileChooser.APPROVE_OPTION) { File directory = chooseDirectory.getCurrentDirectory(); DoseResponseReportSwingWorker doseResponseReportSwingWorker = new DoseResponseReportSwingWorker( directory, chooseDirectory.getSelectedFile().getName()); doseResponseReportSwingWorker.execute(); } else { areaMainController.showMessage("Open command cancelled by user", "", JOptionPane.INFORMATION_MESSAGE); } }
From source file:aurelienribon.gdxsetupui.ui.panels.ConfigUpdatePanel.java
private void browse() { String path = Ctx.cfgUpdate.destinationPath; JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(this); JFileChooser chooser = new JFileChooser(new File(path)); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Select the core project folder"); if (chooser.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) { pathField.setText(chooser.getSelectedFile().getPath()); updateConfig(chooser.getSelectedFile()); updatePanel();/*from w w w.j a v a2s . c o m*/ } }
From source file:be.fedict.eid.tsl.tool.TslInternalFrame.java
@Override public void actionPerformed(ActionEvent event) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Save Signer Certificate"); int result = fileChooser.showSaveDialog(this); if (JFileChooser.APPROVE_OPTION == result) { File file = fileChooser.getSelectedFile(); if (file.exists()) { int confirmResult = JOptionPane.showConfirmDialog(this, "File already exists.\n" + file.getAbsolutePath() + "\n" + "Overwrite file?", "Overwrite", JOptionPane.OK_CANCEL_OPTION); if (JOptionPane.CANCEL_OPTION == confirmResult) { return; }//from www . j a va2 s .c om } try { FileUtils.writeByteArrayToFile(file, this.signerCertificate.getEncoded()); } catch (Exception e) { throw new RuntimeException("error writing file: " + e.getMessage(), e); } } }
From source file:com.nwn.NwnUpdaterHomeView.java
/** * Allow user to specify their NWN directory * @param evt /* www . ja va 2s . com*/ */ private void btnSelectNwnDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelectNwnDirActionPerformed JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new java.io.File(".")); fc.setDialogTitle("NWN Updater"); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setAcceptAllFileFilterUsed(false); int returnVal = fc.showOpenDialog(txtNwnDir); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); txtNwnDir.setText(file.getAbsolutePath()); } }
From source file:jpad.MainEditor.java
public void openFile() { if (_isOSX || ostype == ostype.Linux || ostype == ostype.Other) { openFile_OSX_Nix();/*from ww w.j a v a2 s. c o m*/ } else { JFileChooser fc = new JFileChooser(); fc.setDialogTitle("Open a Text File"); fc.setFileFilter(new FileNameExtensionFilter("Plain Text Files", "txt")); int returnval = fc.showOpenDialog(this); if (returnval == 0) { hasSavedToFile = true; hasChanges = false; curFile = fc.getSelectedFile().getAbsolutePath(); try (FileInputStream stream = new FileInputStream(curFile)) { String file = IOUtils.toString(stream); mainTextArea.setText(file); this.setTitle(String.format("JPad - %s", curFile)); } catch (IOException ex) { JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } }
From source file:com.ejisto.event.listener.SessionRecorderManager.java
private File selectOutputDirectory(Component parent, String directoryPath, boolean saveLastSelectionPath, SettingsRepository settingsRepository) { String targetPath = null;/*from w w w . j a v a 2 s . co m*/ Path savedPath = null; if (StringUtils.isNotBlank(directoryPath)) { savedPath = Paths.get(directoryPath); Path selectionPath = savedPath.getParent(); if (selectionPath != null) { targetPath = selectionPath.toString(); } } JFileChooser fileChooser = new JFileChooser(targetPath); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); fileChooser.setSelectedFile(savedPath != null ? savedPath.toFile() : null); fileChooser.setDialogTitle(getMessage("session.record.save.target")); return GuiUtils.openFileSelectionDialog(parent, saveLastSelectionPath, fileChooser, LAST_OUTPUT_PATH, settingsRepository); }
From source file:net.pandoragames.far.ui.swing.menu.FileMenu.java
private void init(final Localizer localizer, final ComponentRepository componentRepository) { // Import/*from w ww . j av a2 s .c o m*/ JMenuItem importMenu = new JMenuItem(localizer.localize("label.import")); importMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(config.getFileListExportDirectory()); fileChooser.setDialogTitle(localizer.localize("label.select-import-file")); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int returnVal = fileChooser.showOpenDialog(FileMenu.this); if (returnVal == JFileChooser.APPROVE_OPTION) { Runnable fileImporter = new ImportAction(fileChooser.getSelectedFile(), localizer, componentRepository.getOperationCallBackListener(), config.isWindows()); Thread thread = new Thread(fileImporter); thread.setDaemon(true); thread.start(); } } }); this.add(importMenu); // Export export = new JMenuItem(localizer.localize("label.export")); export.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ExportFileListDialog dialog = new ExportFileListDialog(mainFrame, tableModel, config); dialog.pack(); dialog.setVisible(true); } }); this.add(export); // seperator this.addSeparator(); // Edit edit = new JMenuItem(localizer.localize("label.edit")); edit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileEditor editor = new FileEditor(mainFrame, tableModel.getSelectedRows().get(0), config); editor.pack(); editor.setVisible(true); } }); this.add(edit); // View JMenuItem view = new JMenuItem(viewAction); this.add(view); // Preview JMenuItem preview = new JMenuItem(previewAction); this.add(preview); // Info info = new JMenuItem(localizer.localize("label.info")); info.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { InfoView infoView = new InfoView(mainFrame, tableModel.getSelectedRows().get(0), config, repository); infoView.pack(); infoView.setVisible(true); } }); this.add(info); // seperator this.addSeparator(); // copy copy = new JMenuItem(localizer.localize("menu.copy")); copy.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileOperationDialog.copyDialog(tableModel, findForm, errorSink, config, mainFrame); } }); this.add(copy); // tree copy treeCopy = new JMenuItem(localizer.localize("menu.treeCopy")); treeCopy.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileOperationDialog.treeCopyDialog(tableModel, findForm, errorSink, config, mainFrame); } }); this.add(treeCopy); // move move = new JMenuItem(localizer.localize("menu.move")); move.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileOperationDialog.moveDialog(tableModel, findForm, errorSink, config, mainFrame); } }); this.add(move); // delete delete = new JMenuItem(localizer.localize("menu.delete")); delete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileOperationDialog.deleteDialog(tableModel, findForm.getBaseDirectory(), errorSink, config, mainFrame); } }); this.add(delete); // rename rename = new JMenuItem(localizer.localize("menu.rename-dialog")); rename.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int rowIndex = tableModel.getRowIndex(tableModel.getSelectedRows().get(0)); FileOperationDialog.renameDialog(rowIndex, tableModel, findForm, errorSink, config, mainFrame); } }); this.add(rename); }