当前位置: 首页>>代码示例>>Java>>正文


Java FileDialog.setFile方法代码示例

本文整理汇总了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;
}
 
开发者ID:addertheblack,项目名称:myster,代码行数:22,代码来源:DownloaderThread.java

示例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;
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:23,代码来源:KeyStoreEditor.java

示例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;
  }
}
 
开发者ID:tinyMediaManager,项目名称:tinyMediaManager,代码行数:21,代码来源:TmmUIHelper.java

示例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);
    }
}
 
开发者ID:habo,项目名称:stickes,代码行数:21,代码来源:Files.java

示例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;
}
 
开发者ID:george-haddad,项目名称:CIMMYT,代码行数:27,代码来源:FileSave.java

示例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);
    }
}
 
开发者ID:jjaquinta,项目名称:EchoSim,代码行数:23,代码来源:ScriptPanel.java

示例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);
    }
}
 
开发者ID:jjaquinta,项目名称:EchoSim,代码行数:23,代码来源:ScriptPanel.java

示例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);
    }
}
 
开发者ID:jjaquinta,项目名称:EchoSim,代码行数:23,代码来源:ApplicationPanel.java

示例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);
    }
}
 
开发者ID:jjaquinta,项目名称:EchoSim,代码行数:23,代码来源:TestingPanel.java

示例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);
    }
}
 
开发者ID:jjaquinta,项目名称:EchoSim,代码行数:23,代码来源:TestingPanel.java

示例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();
}
 
开发者ID:elki-project,项目名称:elki,代码行数:23,代码来源:ParameterTable.java

示例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);
		}
	}
}
 
开发者ID:SOCR,项目名称:HTML5_WebSite,代码行数:24,代码来源:FrmPrincipalDesk.java

示例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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:11,代码来源:FileDialogElement.java

示例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();
}
 
开发者ID:HML-UnBBayes,项目名称:hml,代码行数:9,代码来源:FileChooserDialog.java

示例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();
}
 
开发者ID:HML-UnBBayes,项目名称:hml,代码行数:9,代码来源:FileChooserDialog.java


注:本文中的java.awt.FileDialog.setFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。