本文整理了Java中javax.swing.JFileChooser.showSaveDialog()
方法的一些代码示例,展示了JFileChooser.showSaveDialog()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFileChooser.showSaveDialog()
方法的具体详情如下:
包路径:javax.swing.JFileChooser
类名称:JFileChooser
方法名:showSaveDialog
暂无
代码示例来源:origin: stackoverflow.com
JFileChooser jFileChooser = new JFileChooser();
jFileChooser.setSelectedFile(new File("fileToSave.txt"));
jFileChooser.showSaveDialog(parent);
代码示例来源:origin: stackoverflow.com
JFileChooser j = new JFileChooser();
j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
Integer opt = j.showSaveDialog(this);
代码示例来源:origin: stanfordnlp/CoreNLP
public File getFile(boolean open) {
File file = null;
int returnVal;
if (open) {
returnVal = fileChooser.showOpenDialog(frame);
} else {
returnVal = fileChooser.showSaveDialog(frame);
}
if(returnVal == JFileChooser.APPROVE_OPTION) {
file = fileChooser.getSelectedFile();
if (open && !checkFile(file)) { file = null; }
}
return file;
}
代码示例来源:origin: stanfordnlp/CoreNLP
private void doExportTree() {
JFileChooser chooser = new JFileChooser();
chooser.setSelectedFile(new File("./tree.png"));
FileNameExtensionFilter filter = new FileNameExtensionFilter("PNG images", "png");
chooser.setFileFilter(filter);
int status = chooser.showSaveDialog(this);
if (status != JFileChooser.APPROVE_OPTION)
return;
Dimension size = tjp.getPreferredSize();
BufferedImage im = new BufferedImage((int) size.getWidth(),
(int) size.getHeight(),
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = im.createGraphics();
tjp.paint(g);
try {
ImageIO.write(im, "png", chooser.getSelectedFile());
} catch (IOException e) {
JOptionPane.showMessageDialog(this, "Failed to save the tree image file.\n"
+ e.getLocalizedMessage(), "Export Error",
JOptionPane.ERROR_MESSAGE);
}
}
代码示例来源:origin: deathmarine/Luyten
public File doSaveAllDialog(String recommendedFileName) {
File selectedFile = null;
initSaveAllDialog();
retrieveSaveDialogDir(fcSaveAll);
fcSaveAll.setSelectedFile(new File(recommendedFileName));
int returnVal = fcSaveAll.showSaveDialog(parent);
saveSaveDialogDir(fcSaveAll);
if (returnVal == JFileChooser.APPROVE_OPTION) {
selectedFile = fcSaveAll.getSelectedFile();
}
return selectedFile;
}
代码示例来源:origin: osmdroid/osmdroid
@Override
public void actionPerformed(final ActionEvent e) {
final JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
jfc.setAcceptAllFileFilterUsed(false);
final int result = jfc.showSaveDialog(null);
if (result == JFileChooser.APPROVE_OPTION) {
txtTempFolder.setText(jfc.getSelectedFile().getAbsolutePath());
}
}
});
代码示例来源:origin: geotools/geotools
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setFileFilter(
int result = chooser.showSaveDialog(CompareImageDialog.this);
if (result == JFileChooser.APPROVE_OPTION) {
File selected = chooser.getSelectedFile();
try {
ImageIO.write(
expected, "PNG", new File(selected, "expected.png"));
ImageIO.write(actual, "PNG", new File(selected, "actual.png"));
} catch (IOException e1) {
LOGGER.log(Level.WARNING, "Failed to save images", e);
代码示例来源:origin: deathmarine/Luyten
public File doSaveDialog(String recommendedFileName) {
File selectedFile = null;
initSaveDialog();
retrieveSaveDialogDir(fcSave);
fcSave.setSelectedFile(new File(recommendedFileName));
int returnVal = fcSave.showSaveDialog(parent);
saveSaveDialogDir(fcSave);
if (returnVal == JFileChooser.APPROVE_OPTION) {
selectedFile = fcSave.getSelectedFile();
}
return selectedFile;
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args){
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("D:\\outlook"));
chooser.showSaveDialog(null);
}
代码示例来源:origin: EngineHub/WorldEdit
public static File showSaveDialog(String[] exts) {
JFileChooser dialog = new JFileChooser();
if (exts != null) {
dialog.setFileFilter(new ExtensionFilter(exts));
}
int returnVal = dialog.showSaveDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
return dialog.getSelectedFile();
}
return null;
}
代码示例来源:origin: stanfordnlp/CoreNLP
public File getFile(boolean open) {
File file = null;
int returnVal;
if (open) {
returnVal = fileChooser.showOpenDialog(frame);
} else {
returnVal = fileChooser.showSaveDialog(frame);
}
if(returnVal == JFileChooser.APPROVE_OPTION) {
file = fileChooser.getSelectedFile();
if (open && !checkFile(file)) { file = null; }
}
return file;
}
代码示例来源:origin: stackoverflow.com
JFileChooser saveFile = new JFileChooser();
saveFile.showSaveDialog(null);
JFileChooser openFile = new JFileChooser();
openFile.showOpenDialog(null);
代码示例来源:origin: winder/Universal-G-Code-Sender
private void exportButtonActionPerformed() {
JFileChooser fileChooser = new JFileChooser();
String date = LocalDate.now().format(DateTimeFormatter.ISO_DATE);
fileChooser.setSelectedFile(new File("firmware_" + date + ".settings"));
fileChooser.setFileFilter(new FirmwareSettingsFileTypeFilter());
if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
FirmwareSettingUtils.exportSettings(file, backend.getController());
}
}
代码示例来源:origin: chewiebug/GCViewer
@Override
public void actionPerformed(final ActionEvent e) {
final GCDocument gcDocument = gcViewer.getSelectedGCDocument();
for (int i=0; i<gcDocument.getChartPanelViewCount(); i++) {
final ChartPanelView chartPanelView = gcDocument.getChartPanelView(i);
final File file = new File(chartPanelView.getGCResource().getResourceName());
saveDialog.setCurrentDirectory(file.getParentFile());
saveDialog.setSelectedFile(file);
final int val = saveDialog.showSaveDialog(gcViewer);
if (val == JFileChooser.APPROVE_OPTION) {
ExportExtensionFileFilter fileFilter = (ExportExtensionFileFilter) saveDialog.getFileFilter();
// On OS/X if you don't select one of the filters and just press "Save" the filter may be null. Use the CSV one then
if (fileFilter==null) {
fileFilter = (ExportExtensionFileFilter) saveDialog.getChoosableFileFilters()[0];
}
exportFile(chartPanelView.getGCResource().getModel(),
saveDialog.getSelectedFile(),
fileFilter.getExtension(),
fileFilter.getDataWriterType());
}
else if (val == JFileChooser.ERROR_OPTION) {
JOptionPane.showMessageDialog(gcViewer, LocalisationHelper.getString("fileexport_dialog_error_occured"), LocalisationHelper.getString("fileexport_dialog_write_file_failed"), JOptionPane.ERROR_MESSAGE);
}
}
}
代码示例来源:origin: stackoverflow.com
JFileChooser fileChooser = new JFileChooser();
fileChooser.setSelectedFile(new File("C:\\file.txt"));
fileChooser.showSaveDialog(null);
代码示例来源:origin: stackoverflow.com
import javax.swing.*;
public class Example
{
public static void main(String[] args)
{
JFileChooser f = new JFileChooser();
f.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
f.showSaveDialog(null);
System.out.println(f.getCurrentDirectory());
System.out.println(f.getSelectedFile());
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Opens a dialog and saves the output of the parser on the current
* text. If there is no current text, yell at the user and make
* them feel bad instead.
*/
public void saveOutput() {
if (textPane.getText().trim().length() == 0) {
JOptionPane.showMessageDialog(this, "No text to parse ", null,
JOptionPane.ERROR_MESSAGE);
return;
}
jfc.setDialogTitle("Save file");
int status = jfc.showSaveDialog(this);
if (status == JFileChooser.APPROVE_OPTION) {
saveOutput(jfc.getSelectedFile().getPath());
}
}
代码示例来源:origin: stackoverflow.com
JScrollPane logScrollPane = new JScrollPane(content);
jfc = new JFileChooser();
jfc.setCurrentDirectory(new File(default_directory));
jfc.setSelectedFile(new File(default_filename));
jfc.addPropertyChangeListener(new PropertyChangeListener() {
jfc.setCurrentDirectory(new File("/home/foo"));
jfc.setSelectedFile(new File("default" + version + ".txt"));
int returnVal = jfc.showSaveDialog(MyFileChooser.this);
if (returnVal == JFileChooser.APPROVE_OPTION)
File file = jfc.getSelectedFile();
代码示例来源:origin: MovingBlocks/Terasology
fileChooser.setSelectedFile(new File(CREATE_NEW_SKIN.equals(selectedAsset)
? "untitled.skin" : selectedAsset.split(":")[1] + ".skin"));
fileChooser.setFileFilter(new FileNameExtensionFilter("Skin asset file (*.skin)", "skin"));
if (fileChooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
saveToFile(fileChooser.getSelectedFile());
deleteAutosave();
代码示例来源:origin: stackoverflow.com
JFileChooser jFileChooser = new JFileChooser();
jFileChooser.setSelectedFile(new File("fileToSave.txt"));
jFileChooser.showSaveDialog(parent);
内容来源于网络,如有侵权,请联系作者删除!