List of usage examples for javax.swing JFileChooser setApproveButtonMnemonic
public void setApproveButtonMnemonic(char mnemonic)
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); // Set the text chooser.setApproveButtonText("New Approve Text"); // Set the mnemonic chooser.setApproveButtonMnemonic('a'); // Set the tool tip chooser.setApproveButtonToolTipText("New Approve Tool Tip"); chooser.showOpenDialog(null);// w w w .jav a2s .c o m }
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); // Set the text chooser.setApproveButtonText("New Approve Text"); // Set the mnemonic chooser.setApproveButtonMnemonic((int) 'a'); // Set the tool tip chooser.setApproveButtonToolTipText("New Approve Tool Tip"); chooser.showOpenDialog(null);//from w w w .j av a2 s . c o m }
From source file:Main.java
public static String browseForFile(Window owner, String file, int selectionMode, String title, FileFilter filter) {// ww w .j ava 2 s . c o m final String curDir = System.getProperty("user.dir"); JFileChooser chooser = new JFileChooser(curDir); chooser.setDialogType(JFileChooser.OPEN_DIALOG); chooser.setFileSelectionMode(selectionMode); chooser.setApproveButtonText("Select"); chooser.setApproveButtonMnemonic('s'); chooser.setDialogTitle(title); if (filter != null) chooser.setFileFilter(filter); if (file != null && !file.isEmpty()) { File curFile = new File(file); chooser.setCurrentDirectory(curFile.getAbsoluteFile().getParentFile()); if (curFile.isDirectory()) { try { chooser.setSelectedFile(curFile.getCanonicalFile()); } catch (IOException ex) { } } else { chooser.setSelectedFile(curFile); } } if (chooser.showOpenDialog(owner) == JFileChooser.APPROVE_OPTION) { String path = chooser.getSelectedFile().getPath(); try { path = new File(path).getCanonicalPath(); } catch (IOException e) { } // make path relative if possible if (path.startsWith(curDir)) { path = "." + path.substring(curDir.length()); } return path; } return null; }
From source file:simMPLS.ui.simulator.JVentanaHija.java
/** * Este mtodo se encarga de controlar que todo ocurre como debe con respecto al * escenario, cuando se pulsa en el men principal la opcin de "Guardar como..." * @since 1.0//from w ww . j a v a 2 s. c o m */ public void gestionarGuardarComo() { anotarDatosDeEscenario(); JFileChooser dialogoGuardar = new JFileChooser(); dialogoGuardar.setFileFilter(new JOSMFilter()); dialogoGuardar.setDialogType(JFileChooser.CUSTOM_DIALOG); dialogoGuardar.setApproveButtonMnemonic('A'); dialogoGuardar.setApproveButtonText(java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes") .getString("JVentanaHija.DialogoGuardar.OK")); dialogoGuardar.setDialogTitle(java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes") .getString("JVentanaHija.DialogoGuardar.Almacenar") + this.getTitle() + java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes").getString("-")); dialogoGuardar.setAcceptAllFileFilterUsed(false); dialogoGuardar.setSelectedFile(new File(this.getTitle())); dialogoGuardar.setFileSelectionMode(JFileChooser.FILES_ONLY); int resultado = dialogoGuardar.showSaveDialog(VentanaPadre); if (resultado == JFileChooser.APPROVE_OPTION) { String ext = null; String nombreFich = dialogoGuardar.getSelectedFile().getPath(); int i = nombreFich.lastIndexOf('.'); if (i > 0 && i < nombreFich.length() - 1) { ext = nombreFich.substring(i + 1).toLowerCase(); } if (ext == null) { nombreFich += java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes").getString(".osm"); } else { if (!ext.equals( java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes").getString("osm"))) { nombreFich += java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes") .getString(".osm"); } } dialogoGuardar.setSelectedFile(new File(nombreFich)); escenario.setFile(dialogoGuardar.getSelectedFile()); this.escenario.setSaved(true); this.setTitle(this.escenario.obtenerFichero().getName()); TOSMSaver almacenador = new TOSMSaver(escenario); // JVentanaBooleana vb = new JVentanaBooleana(this.VentanaPadre, true, this.dispensadorDeImagenes); // vb.mostrarPregunta(java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes").getString("JVentanaHija.PreguntaEmpotrarCRC")); // vb.show(); // boolean conCRC = vb.obtenerRespuesta(); // boolean correcto = almacenador.save(escenario.obtenerFichero(), conCRC); JVentanaBooleana vb = new JVentanaBooleana(this.VentanaPadre, true, this.dispensadorDeImagenes); vb.mostrarPregunta("Do you want to save the routing tables ?"); vb.show(); boolean saveTables = vb.obtenerRespuesta(); boolean correcto = almacenador.save(escenario.obtenerFichero(), false, saveTables); if (correcto) { this.escenario.setModified(false); this.escenario.setSaved(true); } } }
From source file:phex.gui.common.FileDialogHandler.java
private static JFileChooser initDefaultChooser(String title, String approveBtnText, char approveBtnMnemonic, FileFilter filter, int mode, File currentDirectory, String notifyPopupTitle, String notifyPopupShortMessage) { JFileChooser chooser = new JFileChooser(); if (notifyPopupTitle != null || notifyPopupShortMessage != null) { displayNotificationPopup(chooser, notifyPopupTitle, notifyPopupShortMessage); }// w w w . j av a2 s . com if (currentDirectory != null) { chooser.setCurrentDirectory(currentDirectory); } if (filter != null) { chooser.setFileFilter(filter); } chooser.setFileSelectionMode(mode); chooser.setDialogTitle(title); chooser.setApproveButtonText(approveBtnText); chooser.setApproveButtonMnemonic(approveBtnMnemonic); return chooser; }
From source file:us.daveread.basicquery.BasicQuery.java
/** * Exports the results to a file// w ww. j ava 2s .c o m * * @param model * The model for the current results * @param fileType * The export file type */ private void chooseFileForSave(TableModel model, int fileType) { final JFileChooser chooser = new JFileChooser(); int returnVal; chooser.setDialogTitle(Resources.getString("dlgSaveDataTitle")); chooser.setApproveButtonText(Resources.getString("dlgSaveDataButton")); chooser.setApproveButtonMnemonic(Resources.getChar("dlgSaveDataButtonMnemonic")); if (latestFileDirectory != null) { if (latestFileDirectory.isDirectory()) { chooser.setCurrentDirectory(latestFileDirectory); } else if (latestFileDirectory.getParentFile().isDirectory()) { chooser.setCurrentDirectory(latestFileDirectory.getParentFile()); } } returnVal = chooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { latestFileDirectory = chooser.getSelectedFile().getParentFile(); switch (fileType) { case FILE_EXPORT_CSV: saveResultAsCSV(model, chooser.getSelectedFile().getAbsoluteFile()); break; case FILE_EXPORT_TRIPLES: saveResultsAsTriples(model, chooser.getSelectedFile().getAbsoluteFile()); break; default: throw new IllegalArgumentException("Unknown file type mode for export: " + fileType); } } }