List of usage examples for javax.swing JFileChooser setLocation
public void setLocation(int x, int y)
From source file:org.tmpotter.ui.ActionHandler.java
/** * Save project as specified filename.// ww w. j a va 2s. co m */ private void saveProjectAs() { File outFile = new File(modelMediator.getProjectName().concat(".tmpx")); try { boolean save = false; boolean cancel = false; while (!save && !cancel) { final JFileChooser fc = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("TMX File", "tmpx"); fc.setFileFilter(filter); boolean nameOfUser = false; while (!nameOfUser) { fc.setLocation(230, 300); fc.setCurrentDirectory(RuntimePreferences.getUserHome()); fc.setDialogTitle(getString("DLG.SAVEAS")); fc.setMultiSelectionEnabled(false); fc.setSelectedFile(outFile); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); RuntimePreferences.setUserHome(fc.getCurrentDirectory()); int returnVal; returnVal = fc.showSaveDialog(parent); if (returnVal == JFileChooser.APPROVE_OPTION) { outFile = fc.getSelectedFile(); if (!outFile.getName().endsWith(".tmpx")) { outFile = new File(outFile.getName().concat(".tmpx")); } nameOfUser = true; } else { nameOfUser = true; cancel = true; } } int selected; if (nameOfUser && !cancel) { if (outFile.exists()) { final Object[] options = { getString("BTN.SAVE"), getString("BTN.CANCEL") }; selected = JOptionPane.showOptionDialog(parent, getString("MSG.FILE_EXISTS"), getString("MSG.WARNING"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (selected == 0) { save = true; } } else { save = true; } } } if (save) { cleanTmData(); ProjectProperties prop = modelMediator.getProjectProperties(); prop.setFilePathProject(outFile); TmxpWriter.writeTmxp(prop, tmData.getDocumentOriginal(), tmData.getDocumentTranslation()); } } catch (Exception ex) { JOptionPane.showMessageDialog(parent, JOptionPane.ERROR_MESSAGE); } }