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


Java FileDialog.setVisible方法代码示例

本文整理汇总了Java中java.awt.FileDialog.setVisible方法的典型用法代码示例。如果您正苦于以下问题:Java FileDialog.setVisible方法的具体用法?Java FileDialog.setVisible怎么用?Java FileDialog.setVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.FileDialog的用法示例。


在下文中一共展示了FileDialog.setVisible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showFileDialog

import java.awt.FileDialog; //导入方法依赖的package包/类
private File showFileDialog( FileDialog fileDialog, int mode ) {
    String oldFileDialogProp = System.getProperty("apple.awt.fileDialogForDirectories"); //NOI18N
    if( dirsOnly ) {
        System.setProperty("apple.awt.fileDialogForDirectories", "true"); //NOI18N
    }
    fileDialog.setMode( mode );
    fileDialog.setVisible(true);
    if( dirsOnly ) {
        if( null != oldFileDialogProp ) {
            System.setProperty("apple.awt.fileDialogForDirectories", oldFileDialogProp); //NOI18N
        } else {
            System.clearProperty("apple.awt.fileDialogForDirectories"); //NOI18N
        }
    }
    if( fileDialog.getDirectory() != null && fileDialog.getFile() != null ) {
        String selFile = fileDialog.getFile();
        File dir = new File( fileDialog.getDirectory() );
        return new File( dir, selFile );
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:FileChooserBuilder.java

示例2: showSaveDialog

import java.awt.FileDialog; //导入方法依赖的package包/类
public int showSaveDialog(Component parent) {
  final FileDialog fd = awt_file_dialog_init(parent);
  fd.setMode(FileDialog.SAVE);
  fd.setVisible(true);

  final int value;
  if (fd.getFile() != null) {
    cur = new File(fd.getDirectory(), fd.getFile());
    value = FileChooser.APPROVE_OPTION;
  }
  else {
    value = FileChooser.CANCEL_OPTION;
  }
  updateDirectoryPreference();
  return value;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:17,代码来源:FileChooser.java

示例3: showOpenDialog

import java.awt.FileDialog; //导入方法依赖的package包/类
public int showOpenDialog(Component parent) {
  final FileDialog fd = awt_file_dialog_init(parent);
  fd.setMode(FileDialog.LOAD);
  System.setProperty("apple.awt.fileDialogForDirectories",
                     String.valueOf(mode == DIRECTORIES_ONLY));
  fd.setVisible(true);

  final int value;
  if (fd.getFile() != null) {
    cur = new File(fd.getDirectory(), fd.getFile());
    value = FileChooser.APPROVE_OPTION;
  }
  else {
    value = FileChooser.CANCEL_OPTION;
  }
  updateDirectoryPreference();
  return value;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:19,代码来源:FileChooser.java

示例4: actionPerformed

import java.awt.FileDialog; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    FileDialog fileDialog = new FileDialog(ImageViewerGui.getMainFrame(), "Choose a file", FileDialog.LOAD);
    // does not work on Windows
    fileDialog.setFilenameFilter(new AllFilenameFilter());
    fileDialog.setMultipleMode(true);
    fileDialog.setDirectory(Settings.getSingletonInstance().getProperty("default.local.path"));
    fileDialog.setVisible(true);

    String directory = fileDialog.getDirectory();
    File[] fileNames = fileDialog.getFiles();
    if (fileNames.length > 0 && directory != null) {
        // remember the current directory for future
        Settings.getSingletonInstance().setProperty("default.local.path", directory);
        Settings.getSingletonInstance().save("default.local.path");
        for (File fileName : fileNames) {
            if (fileName.isFile())
                Load.image.get(fileName.toURI());
        }
    }
}
 
开发者ID:Helioviewer-Project,项目名称:JHelioviewer-SWHV,代码行数:22,代码来源:OpenLocalFileAction.java

示例5: actionPerformed

import java.awt.FileDialog; //导入方法依赖的package包/类
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);
	}

}
 
开发者ID:ljheee,项目名称:MySnakeGame,代码行数:23,代码来源:SnakeGameFrame.java

示例6: main

import java.awt.FileDialog; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private static void main(String[] s) {
	try {
		JFrame frame = new JFrame();
		FileDialog fd = new FileDialog(frame);
		fd.setFilenameFilter(new SuffixFilenameFilter("wav", "wave"));
		fd.pack();
		fd.setVisible(true);
		if(fd.getFile()==null) return;
		File wavFile = new File(fd.getDirectory()+fd.getFile());
		FileInputStream in = null;
		try {
			in = new FileInputStream(wavFile);
			System.err.println("length: " + wavFile.length());
			WavCopier r = new WavCopier(in);
		} finally {
			in.close();
		}
		System.exit(0);
	} catch(IOException e) {
		e.printStackTrace();
		System.exit(1);
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:25,代码来源:WavCopier.java

示例7: showSaveDialog

import java.awt.FileDialog; //导入方法依赖的package包/类
public static File showSaveDialog(Frame f,String title,String extension) {
	if(extension.startsWith("."))
		extension = extension.substring(1);
	
	FileDialog fd = new FileDialog(f, title);
	fd.setMode(FileDialog.SAVE);
	fd.setFilenameFilter(new SuffixFilenameFilter(extension));
	fd.pack();
	fd.setLocationRelativeTo(null);
	fd.setVisible(true);

	String s = fd.getFile();
	if(s==null)
		return null;
	
	if(s.toLowerCase().endsWith("."+extension)) {
		return new File(fd.getDirectory() + s);
	}
	
	return new File(fd.getDirectory() + fd.getFile()+"."+extension);
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:22,代码来源:FileDialogUtils.java

示例8: doBrowseForFile

import java.awt.FileDialog; //导入方法依赖的package包/类
protected void doBrowseForFile(AudioPlayerComponent apc) {
	Window w = SwingUtilities.getWindowAncestor(apc);
	if(!(w instanceof Frame))
		throw new RuntimeException("cannot invoke a FileDialog if the player is not in a java.awt.Frame");
	//the button shouldn't be enabled if w isn't a Frame...
	Frame f = (Frame)w;
	FileDialog fd = new FileDialog(f);
	fd.pack();
	fd.setLocationRelativeTo(null);
	fd.setVisible(true);
	
	if(fd.getFile()==null) throw new UserCancelledException();
	File file = new File(fd.getDirectory()+fd.getFile());
	try {
		apc.setSource( file.toURI().toURL() );
	} catch (MalformedURLException e) {
		e.printStackTrace();
		apc.setSource(null);
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:21,代码来源:AudioPlayerUI.java

示例9: showSaveDialog

import java.awt.FileDialog; //导入方法依赖的package包/类
protected File showSaveDialog() {
	FileDialog fd = new FileDialog(frame);
	fd.setMode(FileDialog.SAVE);
	fd.setFilenameFilter(new SuffixFilenameFilter("mov"));
	fd.setTitle("Save MOV File");
	fd.pack();
	fd.setLocationRelativeTo(frame);
	fd.setVisible(true);
	if(fd.getFile()==null)
		throw new UserCancelledException();
	String filepath = fd.getDirectory() + fd.getFile();
	if(!filepath.toLowerCase().endsWith(".mov")) {
		filepath += ".mov";
	}
	return new File(filepath);
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:17,代码来源:ScreenCaptureDemo.java

示例10: browseForFile

import java.awt.FileDialog; //导入方法依赖的package包/类
/** If invoked from within a Frame: this pulls up a FileDialog to
 * browse for a file. If this is invoked from a secure applet: then
 * this will throw an exception.
 * 
 * @param ext an optional list of extensions
 * @return a File, or null if the user declined to select anything.
 */
public File browseForFile(String... ext) {
	Window w = SwingUtilities.getWindowAncestor(this);
	if(!(w instanceof Frame))
		throw new IllegalStateException();
	Frame frame = (Frame)w;
	FileDialog fd = new FileDialog(frame);
	if(ext!=null && ext.length>0 && (!(ext.length==1 && ext[0]==null)))
		fd.setFilenameFilter(new SuffixFilenameFilter(ext));
	fd.pack();
	fd.setLocationRelativeTo(null);
	fd.setVisible(true);
	String d = fd.getFile();
	if(d==null) return null;
	return new File(fd.getDirectory()+fd.getFile());
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:23,代码来源:ImageQuantizationDemo.java

示例11: main

import java.awt.FileDialog; //导入方法依赖的package包/类
/** This captures a File's icon and saves it as a PNG.
 * This is tested on Mac; I'm not sure how it will perform
 * on Windows. You may need to modify the icon size. As of this
 * writing on Mac: you can pass most any Dimension object and
 * the icon will scale upwards safely.
 */
public static void main(String[] args) throws IOException {
	FileDialog fd = new FileDialog(new Frame());
	fd.pack();
	fd.setVisible(true);
	File f = new File(fd.getDirectory()+fd.getFile());
	Icon icon = getIcon(f);
	icon = new ScaledIcon(icon, 24, 24);
	BufferedImage bi = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
	Graphics2D g = bi.createGraphics();
	icon.paintIcon(null, g, 0, 0);
	g.dispose();
	File f2 = new File(f.getParentFile(), f.getName()+".png");
	if(f2.exists())
		System.exit(1);
	ImageIO.write(bi, "png", f2);
	System.exit(0);;
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:24,代码来源:FileIcon.java

示例12: 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

示例13: loadTransformation

import java.awt.FileDialog; //导入方法依赖的package包/类
private void loadTransformation (
) {
   final Frame f = new Frame();
   final FileDialog fd = new FileDialog(f, "Load Transformation", FileDialog.LOAD);
   fd.setVisible(true);
   final String path = fd.getDirectory();
   final String filename = fd.getFile();
   if ((path == null) || (filename == null)) {
      return;
   }
   String fn_tnf=path+filename;

   int intervals=unwarpJMiscTools.
      numberOfIntervalsOfTransformation(fn_tnf);
   double [][]cx=new double[intervals+3][intervals+3];
   double [][]cy=new double[intervals+3][intervals+3];
   unwarpJMiscTools.loadTransformation(fn_tnf, cx, cy);

   // Apply transformation
   dialog.applyTransformationToSource(intervals,cx,cy);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:22,代码来源:UnwarpJ_.java

示例14: openDirectoryDialog

import java.awt.FileDialog; //导入方法依赖的package包/类
private static Path openDirectoryDialog(String title, String initialPath) throws Exception, Error {
  // set system property to choose directories
  System.setProperty("apple.awt.fileDialogForDirectories", "true");

  FileDialog chooser = new FileDialog(MainWindow.getFrame(), title);
  if (StringUtils.isNotBlank(initialPath)) {
    Path path = Paths.get(initialPath);
    if (Files.exists(path)) {
      chooser.setDirectory(path.toFile().getAbsolutePath());
    }
  }
  chooser.setVisible(true);

  // reset system property
  System.setProperty("apple.awt.fileDialogForDirectories", "false");

  if (StringUtils.isNotEmpty(chooser.getFile())) {
    return Paths.get(chooser.getDirectory(), chooser.getFile());
  }
  else {
    return null;
  }
}
 
开发者ID:tinyMediaManager,项目名称:tinyMediaManager,代码行数:24,代码来源:TmmUIHelper.java

示例15: saveEffect

import java.awt.FileDialog; //导入方法依赖的package包/类
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.");
    }
}
 
开发者ID:atomixnmc,项目名称:Atom2DEditor,代码行数:25,代码来源:EffectPanel.java


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