本文整理汇总了Java中java.awt.FileDialog.SAVE属性的典型用法代码示例。如果您正苦于以下问题:Java FileDialog.SAVE属性的具体用法?Java FileDialog.SAVE怎么用?Java FileDialog.SAVE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.FileDialog
的用法示例。
在下文中一共展示了FileDialog.SAVE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showNativeDialog
private void showNativeDialog() {
String dirname = fd.getDirectory();
// File path has a priority against directory path.
String filename = fd.getFile();
if (filename != null) {
final File file = new File(filename);
if (fd.getMode() == FileDialog.LOAD
&& dirname != null
&& file.getParent() == null) {
// File path for gtk_file_chooser_set_filename.
filename = dirname + (dirname.endsWith(File.separator) ? "" :
File.separator) + filename;
}
if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) {
// Filename for gtk_file_chooser_set_current_name.
filename = file.getName();
// Directory path for gtk_file_chooser_set_current_folder.
dirname = file.getParent();
}
}
run(fd.getTitle(), fd.getMode(), dirname, filename,
fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY());
}
示例2: showNativeDialog
private void showNativeDialog() {
String dirname = fd.getDirectory();
// File path has a priority against directory path.
String filename = fd.getFile();
if (filename != null) {
final File file = new File(filename);
if (fd.getMode() == FileDialog.LOAD
&& dirname != null
&& file.getParent() == null) {
// File path for gtk_file_chooser_set_filename.
filename = dirname + (dirname.endsWith(File.separator) ? "" :
File.separator) + filename;
}
if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) {
// Filename for gtk_file_chooser_set_current_name.
filename = file.getName();
// Directory path for gtk_file_chooser_set_current_folder.
dirname = file.getParent();
}
}
if (!quit) {
run(fd.getTitle(), fd.getMode(), dirname, filename,
fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY());
}
}
示例3: askUser
private static String[] askUser(ProgressWindow progress, String dp, String initialFileName, String a) {
String ask = (a == null ? "What do you want to call this file?" : a);
String[] s = new String[2];
FileDialog dialog = new FileDialog(progress, ask, FileDialog.SAVE);
dialog.setSize(400, 300);
dialog.setDirectory(dp);
dialog.setFile(initialFileName);
dialog.show();
String temppath = dialog.getDirectory();
String chosenFileName = dialog.getFile();
if (chosenFileName == null) {
progress.setText("User Cancelled", FileProgressWindow.BAR_1);
return null;
}
s[0] = temppath;
s[1] = chosenFileName;
return s;
}
示例4: actionPerformed
public void actionPerformed(ActionEvent event) {
if (panel.getGameState() == GameState.INITIALIZE) {
JOptionPane.showConfirmDialog(SnakeGameFrame.this,
"��Ϸû������\n���ܱ�����Ϸ����", "̰������Ϸ",
JOptionPane.DEFAULT_OPTION);
return;
}
FileDialog dialog = new FileDialog(SnakeGameFrame.this, "Save",FileDialog.SAVE);
dialog.setVisible(true);
String dir = dialog.getDirectory();
String fileName = dialog.getFile();//��ȡ����������������ġ�Ҫ������ļ�����
String filePath = dir + fileName;
if (fileName != null && fileName.trim().length() != 0) {
File file = new File(filePath);
panel.saveGameDataToFile(file);
} else {
JOptionPane.showConfirmDialog(SnakeGameFrame.this,
"�ļ���Ϊ��\n������Ϸ����ʧ��", "̰������Ϸ", JOptionPane.DEFAULT_OPTION);
}
}
示例5: create
public static KeyStoreEditor create(Frame parentWindow) {
KeyStoreEditor editor = new KeyStoreEditor();
String dialogTitle = "Create Keystore";
Icon icon = QDialog.getIcon(QDialog.PLAIN_MESSAGE);
QDialog.showDialog(parentWindow, dialogTitle, icon, editor, editor.footer, true, null, null);
JComponent button = editor.footer.getLastSelectedComponent();
if( button==editor.footer.getButton(DialogFooter.OK_OPTION) ) {
FileDialog fd = new FileDialog(parentWindow, "Create Keystore", FileDialog.SAVE);
fd.setFilenameFilter(new SuffixFilenameFilter("jks"));
fd.setFile("keystore.jks");
fd.pack();
fd.setLocationRelativeTo(null);
fd.setVisible(true);
if(fd.getFile()==null)
return null;
editor.jksFile = new File(fd.getDirectory()+fd.getFile());
editor.create(false);
return editor;
} else {
return null;
}
}
示例6: doSaveDisk
private void doSaveDisk()
{
FileDialog fd = new FileDialog(getFrame(), "Save Suite", FileDialog.SAVE);
fd.setDirectory(RuntimeLogic.getProp("suite.file.dir"));
fd.setFile(RuntimeLogic.getProp("suite.file.file"));
fd.setVisible(true);
if (fd.getDirectory() == null)
return;
String historyFile = fd.getDirectory()+System.getProperty("file.separator")+fd.getFile();
if ((historyFile == null) || (historyFile.length() == 0))
return;
try
{
SuiteLogic.save(mRuntime, new File(historyFile));
RuntimeLogic.setProp("suite.file.dir", fd.getDirectory());
RuntimeLogic.setProp("suite.file.file", fd.getFile());
}
catch (IOException e)
{
JOptionPane.showMessageDialog(this, e.getLocalizedMessage(), "Error reading "+historyFile, JOptionPane.ERROR_MESSAGE);
}
}
示例7: doSave
private void doSave()
{
FileDialog fd = new FileDialog(getFrame(), "Save History File", FileDialog.SAVE);
fd.setDirectory(RuntimeLogic.getProp("history.file.dir"));
fd.setFile(RuntimeLogic.getProp("history.file.file"));
fd.setVisible(true);
if (fd.getDirectory() == null)
return;
String historyFile = fd.getDirectory()+System.getProperty("file.separator")+fd.getFile();
if ((historyFile == null) || (historyFile.length() == 0))
return;
try
{
RuntimeLogic.saveHistory(mRuntime, new File(historyFile));
RuntimeLogic.setProp("history.file.dir", fd.getDirectory());
RuntimeLogic.setProp("history.file.file", fd.getFile());
}
catch (IOException e)
{
JOptionPane.showMessageDialog(this, e.getLocalizedMessage(), "Error reading "+historyFile, JOptionPane.ERROR_MESSAGE);
}
}
示例8: savePostSript
public void savePostSript(FrmPiz frmpiz) throws Exception {
String sPath;
String sNameNoExt = Jpan_btn.getFileNameNoExt();
final FileDialog fd = new FileDialog(fDialog, "Unable to load the dendrogram properties"
+ " EPS", FileDialog.SAVE);
fd.setFile(sNameNoExt + ".eps");
fd.setVisible(true);
fDialog.setVisible(true);
if (fd.getFile() != null) {
sPath = fd.getDirectory() + fd.getFile();
try {
new EPSExporter(cfg, frmpiz, sPath);
FesLog.LOG.info("Imatge EPS emmagatzemada amb exit");
} catch (Exception e) {
String msg_err = "Unable to save the image";
FesLog.LOG.throwing("FrmPrincipalDesk",
"savePostScript(final BufferedImage buff)", e);
throw new Exception(msg_err);
}
}
}
示例9: saveEffect
void saveEffect() {
FileDialog dialog = new FileDialog(editor, "Save Effect", FileDialog.SAVE);
if (lastDir != null) {
dialog.setDirectory(lastDir);
}
dialog.setVisible(true);
String file = dialog.getFile();
String dir = dialog.getDirectory();
if (dir == null || file == null || file.trim().length() == 0) {
return;
}
lastDir = dir;
int index = 0;
for (ParticleEmitter emitter : editor.effect.getEmitters()) {
emitter.setName((String) emitterTableModel.getValueAt(index++, 0));
}
try {
editor.effect.save(new File(dir, file));
} catch (Exception ex) {
System.out.println("Error saving effect: " + new File(dir, file).getAbsolutePath());
ex.printStackTrace();
JOptionPane.showMessageDialog(editor, "Error saving effect.");
}
}
示例10: openFileDialog
private static Path openFileDialog(String title, String initialPath, int mode, String filename) throws Exception, Error {
FileDialog chooser = new FileDialog(MainWindow.getFrame(), title, mode);
if (StringUtils.isNotBlank(initialPath)) {
Path path = Paths.get(initialPath);
if (Files.exists(path)) {
chooser.setDirectory(path.toFile().getAbsolutePath());
}
}
if (mode == FileDialog.SAVE) {
chooser.setFile(filename);
}
chooser.setVisible(true);
if (StringUtils.isNotEmpty(chooser.getFile())) {
return Paths.get(chooser.getDirectory(), chooser.getFile());
}
else {
return null;
}
}
示例11: saveConsole
private void saveConsole(java.awt.event.ActionEvent evt) {
String text = mainTextArea.getText();
FileDialog fc = new FileDialog(this.getFrame(),
"Save ProtTest console", FileDialog.SAVE);
fc.setDirectory(System.getProperty("user.dir"));
fc.setVisible(true);
String dataFileName = fc.getFile();
try {
File f = new File(dataFileName);
FileWriter fw = new FileWriter(f);
fw.write(text);
fw.close();
} catch (IOException ex) {
Logger.getLogger(XProtTestView.class.getName()).log(Level.SEVERE,
null, ex);
}
}
示例12: doSaveAs
private void doSaveAs () {
FileDialog fileDialog = new FileDialog (this, "Save As...", FileDialog.SAVE);
fileDialog.show ();
if (fileDialog.getFile () == null)
return;
fileName = fileDialog.getDirectory () + File.separator + fileDialog.getFile ();
doSave (fileName);
}
示例13: doSaveAs
/** Asks for a file name. then saves the current content of editor pane to the file.
*/
private void doSaveAs() {
FileDialog fileDialog = new FileDialog(this, "Save As...", FileDialog.SAVE);
fileDialog.show();
if (fileDialog.getFile() == null)
return;
fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile();
doSave(fileName);
}
示例14: actionPerformed
/**
* This method cannot be called directly.
*/
@Override
public void actionPerformed(ActionEvent e) {
FileDialog chooser = new FileDialog(StdDraw.frame, "Use a .png or .jpg extension", FileDialog.SAVE);
chooser.setVisible(true);
String filename = chooser.getFile();
if (filename != null) {
StdDraw.save(chooser.getDirectory() + File.separator + chooser.getFile());
}
}
示例15: actionPerformed
/**
* Opens a save dialog box when the user selects "Save As" from the menu.
*/
@Override
public void actionPerformed(ActionEvent e) {
FileDialog chooser = new FileDialog(frame,
"Use a .png or .jpg extension", FileDialog.SAVE);
chooser.setVisible(true);
if (chooser.getFile() != null) {
save(chooser.getDirectory() + File.separator + chooser.getFile());
}
}