本文整理汇总了Java中java.awt.FileDialog.setFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileDialog.setFile方法的具体用法?Java FileDialog.setFile怎么用?Java FileDialog.setFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.FileDialog
的用法示例。
在下文中一共展示了FileDialog.setFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: askUser
import java.awt.FileDialog; //导入方法依赖的package包/类
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;
}
示例2: create
import java.awt.FileDialog; //导入方法依赖的package包/类
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;
}
}
示例3: openFileDialog
import java.awt.FileDialog; //导入方法依赖的package包/类
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;
}
}
示例4: loadDialog
import java.awt.FileDialog; //导入方法依赖的package包/类
void loadDialog() {
FileDialog fd = new FileDialog(visual.frame, "Choose a file", FileDialog.LOAD);
fd.setFilenameFilter(sf.getLoadFilenameFilter());
fd.setFile("*");
fd.setVisible(true);
if (fd.getFiles().length == 0) {
return;
}
File f = fd.getFiles()[0];
try {
if (f.exists()) {
importFile(f);
visual.init(2);
} else {
JOptionPane.showMessageDialog(visual.frame, f.getName() + " does not exist");
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(visual.frame, "error loading " + f.getName() + ": " + ex);
}
}
示例5: saveFileMac
import java.awt.FileDialog; //导入方法依赖的package包/类
public static final File saveFileMac(String title, File startDirectory, final String fileDesc, String defaultFileName) {
File path = null;
System.setProperty("apple.awt.fileDialogForDirectories", "true");
FileDialog d = new FileDialog((Dialog)null, title, FileDialog.SAVE);
if(defaultFileName != null) {
d.setFile(defaultFileName);
}
d.setFilenameFilter(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return dir.isDirectory() || dir.isFile();
}
});
d.setVisible(true);
String tmp = d.getFile();
if(tmp != null) {
path = new File(tmp);
}
return path;
}
示例6: doLoadDisk
import java.awt.FileDialog; //导入方法依赖的package包/类
private void doLoadDisk()
{
FileDialog fd = new FileDialog(getFrame(), "Load Script", FileDialog.LOAD);
fd.setDirectory(RuntimeLogic.getProp("script.file.dir"));
fd.setFile(RuntimeLogic.getProp("script.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
{
ScriptLogic.load(mRuntime, new File(historyFile));
RuntimeLogic.setProp("script.file.dir", fd.getDirectory());
RuntimeLogic.setProp("script.file.file", fd.getFile());
}
catch (IOException e)
{
JOptionPane.showMessageDialog(this, e.getLocalizedMessage(), "Error reading "+historyFile, JOptionPane.ERROR_MESSAGE);
}
}
示例7: doSaveDisk
import java.awt.FileDialog; //导入方法依赖的package包/类
private void doSaveDisk()
{
FileDialog fd = new FileDialog(getFrame(), "Save Script", FileDialog.SAVE);
fd.setDirectory(RuntimeLogic.getProp("script.file.dir"));
fd.setFile(RuntimeLogic.getProp("script.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
{
ScriptLogic.saveScript(mRuntime, new File(historyFile));
RuntimeLogic.setProp("script.file.dir", fd.getDirectory());
RuntimeLogic.setProp("script.file.file", fd.getFile());
}
catch (IOException e)
{
JOptionPane.showMessageDialog(this, e.getLocalizedMessage(), "Error reading "+historyFile, JOptionPane.ERROR_MESSAGE);
}
}
示例8: doUtteranceLoadFile
import java.awt.FileDialog; //导入方法依赖的package包/类
protected void doUtteranceLoadFile()
{
FileDialog fd = new FileDialog(getFrame(), "Load Utterance File", FileDialog.LOAD);
fd.setDirectory(RuntimeLogic.getProp("utterance.file.dir"));
fd.setFile(RuntimeLogic.getProp("utterance.file.file"));
fd.setVisible(true);
if (fd.getDirectory() == null)
return;
String intentFile = fd.getDirectory()+System.getProperty("file.separator")+fd.getFile();
if ((intentFile == null) || (intentFile.length() == 0))
return;
try
{
RuntimeLogic.readUtterances(mRuntime, (new File(intentFile)).toURI());
RuntimeLogic.setProp("utterance.file.dir", fd.getDirectory());
RuntimeLogic.setProp("utterance.file.file", fd.getFile());
}
catch (IOException e)
{
JOptionPane.showMessageDialog(this, e.getLocalizedMessage(), "Error reading "+intentFile, JOptionPane.ERROR_MESSAGE);
}
}
示例9: doSave
import java.awt.FileDialog; //导入方法依赖的package包/类
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);
}
}
示例10: doLoad
import java.awt.FileDialog; //导入方法依赖的package包/类
private void doLoad()
{
FileDialog fd = new FileDialog(getFrame(), "Load History File", FileDialog.LOAD);
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.loadHistory(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);
}
}
示例11: actionPerformed
import java.awt.FileDialog; //导入方法依赖的package包/类
/**
* Button callback to show the file selector
*/
@Override
public void actionPerformed(ActionEvent e) {
FileDialog fc = new FileDialog(frame);
fc.setDirectory(defaultpath);
fc.setMode(mode);
final String curr = textfield.getText();
if(curr != null && curr.length() > 0) {
fc.setFile(curr);
}
fc.setVisible(true);
String filename = fc.getFile();
if(filename != null) {
textfield.setText(new File(fc.getDirectory(), filename).getPath());
}
fc.setVisible(false);
fc.dispose();
textfield.requestFocus();
fireEditingStopped();
}
示例12: savePostSript
import java.awt.FileDialog; //导入方法依赖的package包/类
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);
}
}
}
示例13: sendKeys
import java.awt.FileDialog; //导入方法依赖的package包/类
@Override public void sendKeys(CharSequence... keysToSend) {
FileDialog fileDialog = (FileDialog) dialog.getWindow();
String filePath = (String) keysToSend[0];
String setPath = "";
if (filePath != null && !"".equals(filePath)) {
setPath = ChooserHelper.decodeFile(filePath).getPath();
}
fileDialog.setFile(setPath);
fileDialog.setVisible(false);
}
示例14: loadFile
import java.awt.FileDialog; //导入方法依赖的package包/类
public String loadFile(Frame f, String title, String defDir, String fileType) {
FileDialog fd = new FileDialog(f, title, FileDialog.LOAD);
fd.setFile(fileType);
fd.setDirectory(defDir);
fd.setLocation(50, 50);
fd.show();
return fd.getDirectory()+fd.getFile();
}
示例15: saveFile
import java.awt.FileDialog; //导入方法依赖的package包/类
public String saveFile(Frame f, String title, String defDir, String fileType) {
FileDialog fd = new FileDialog(f, title, FileDialog.SAVE);
fd.setFile(fileType);
fd.setDirectory(defDir);
fd.setLocation(50, 50);
fd.show();
return fd.getDirectory()+fd.getFile();
}