本文整理了Java中java.awt.FileDialog.show()
方法的一些代码示例,展示了FileDialog.show()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileDialog.show()
方法的具体详情如下:
包路径:java.awt.FileDialog
类名称:FileDialog
方法名:show
暂无
代码示例来源:origin: stackoverflow.com
public Document loadXmlFile(Frame frame, DocumentBuilder docBuilder, String startPath) {
FileDialog fd = new FileDialog(frame, "Loadxml-title", FileDialog.LOAD);
//Add type filter
fd.setDirectory(startPath));
fd.show();
String file = fd.getFile();
if(file == null) {
return null;
}
return docBuilder.parse(file);
}
代码示例来源:origin: stackoverflow.com
void imageload () {
FileDialog fd = new FileDialog(MainFram.this,"Open", FileDialog.LOAD);
fd.show();
if(fd.getFile() == null){
//Label1.setText("You have not chosen any image files yet");
}
else{
String d = (fd.getDirectory() + fd.getFile());
//Toolkit toolkit = Toolkit.getDefaultToolkit();
//Image1 = toolkit.getImage(d);`
//Object saveImage=Image1;
insertImage(d) //Db function
代码示例来源:origin: stackoverflow.com
DateFileFilter filter = new DateFileFilter();
FileDialog dialog = new FileDialog(parent, "Choose File");
dialog.setFilenameFilter(filter);
dialog.show();
String selectedFile = dialog.getFile();
代码示例来源:origin: com.nativelibs4java/javacl-demos-jna
static File chooseFile() {
if (Platform.isMac()) {
FileDialog d = new FileDialog((java.awt.Frame)null);
d.setMode(FileDialog.LOAD);
d.show();
String f = d.getFile();
if (f != null)
return new File(new File(d.getDirectory()), d.getFile());
} else {
JFileChooser chooser = new JFileChooser();
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
return chooser.getSelectedFile();
}
return null;
}
public static void main(String[] args) {
代码示例来源:origin: nativelibs4java/JavaCL
static File chooseFile() {
if (Platform.isMacOSX()) {
FileDialog d = new FileDialog((java.awt.Frame)null);
d.setMode(FileDialog.LOAD);
d.show();
String f = d.getFile();
if (f != null)
return new File(new File(d.getDirectory()), d.getFile());
} else {
JFileChooser chooser = new JFileChooser();
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
return chooser.getSelectedFile();
}
return null;
}
public static void main(String[] args) {
代码示例来源:origin: org.appdapter/org.appdapter.lib.gui
@Override public File call(Class box, Object... params) {
FileDialog dialog = new FileDialog(Utility.getAppFrame(), "Load... ", FileDialog.LOAD);
dialog.show();
String fileName = dialog.getFile();
String directory = dialog.getDirectory();
if (directory == null && fileName == null)
return null;
return new File(directory, fileName);
}
代码示例来源:origin: com.nativelibs4java/javacl-demos
static File chooseFile() {
if (Platform.isMacOSX()) {
FileDialog d = new FileDialog((java.awt.Frame)null);
d.setMode(FileDialog.LOAD);
d.show();
String f = d.getFile();
if (f != null)
return new File(new File(d.getDirectory()), d.getFile());
} else {
JFileChooser chooser = new JFileChooser();
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
return chooser.getSelectedFile();
}
return null;
}
public static void main(String[] args) {
代码示例来源:origin: nativelibs4java/JavaCL
@SuppressWarnings("deprecation")
@Override
public void actionPerformed(ActionEvent ae) {
boolean paused = demo.paused;
demo.paused = true;
BufferedImage im = new BufferedImage(canvas.getWidth(), canvas.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics g = im.createGraphics();
canvas.paint(g);
g.dispose();
FileDialog fc = new FileDialog((Frame)null);
fc.setMode(FileDialog.SAVE);
fc.show();
if (fc.getFile() != null) {
try {
ImageIO.write(im, "jpeg", lastFile = new File(new File(fc.getDirectory()), fc.getFile()));
} catch (Exception ex) {
ParticlesDemo.exception(ex);
Logger.getLogger(ParticlesDemo.class.getName()).log(Level.SEVERE, null, ex);
}
}
demo.paused = paused;
}
代码示例来源:origin: org.nakedobjects/nos-viewer-dnd
public String selectFilePath(final String title, final String directory) {
FileDialog dlg = new FileDialog(this, title);
dlg.show();
String path = dlg.getDirectory() + dlg.getFile();
return path;
}
}
代码示例来源:origin: nativelibs4java/JavaCL
public static File chooseFile(File initialFile, boolean load) {
if (isMac()) {
FileDialog d = new FileDialog((java.awt.Frame)null);
d.setMode(load ? FileDialog.LOAD : FileDialog.SAVE);
if (initialFile != null) {
d.setDirectory(initialFile.getParent());
d.setFile(initialFile.getName());
}
d.show();
String f = d.getFile();
if (f != null)
return new File(new File(d.getDirectory()), d.getFile());
} else {
JFileChooser chooser = new JFileChooser();
if (initialFile != null)
chooser.setSelectedFile(initialFile);
if ((load ? chooser.showOpenDialog(null) : chooser.showSaveDialog(null)) == JFileChooser.APPROVE_OPTION)
return chooser.getSelectedFile();
}
return null;
}
代码示例来源:origin: nativelibs4java/JavaCL
@SuppressWarnings("deprecation")
@Override
public void actionPerformed(ActionEvent ae) {
boolean paused = demo.paused;
demo.paused = true;
FileDialog fc = new FileDialog((Frame)null);
fc.setMode(FileDialog.LOAD);
fc.show();
if (fc.getFile() != null) {
try {
BufferedImage im = ImageIO.read(lastFile = new File(new File(fc.getDirectory()), fc.getFile()));
demo.setImage(im);
} catch (Exception ex) {
ParticlesDemo.exception(ex);
Logger.getLogger(ParticlesDemo.class.getName()).log(Level.SEVERE, null, ex);
}
}
demo.paused = paused;
}
代码示例来源:origin: org.appdapter/org.appdapter.lib.gui
void saveCollectionAs() {
FileDialog dialog = new FileDialog(getFrame(), "Save " + getCollectionName(), FileDialog.SAVE);
dialog.setFile("mycollection.ser");
dialog.show();
String fileName = dialog.getFile();
String directory = dialog.getDirectory();
theLogger.debug("fileName = " + fileName);
theLogger.debug("directory = " + directory);
if (fileName != null) {
saveCollection(new File(directory, fileName));
}
}
代码示例来源:origin: org.appdapter/org.appdapter.lib.gui
void openCollection() {
FileDialog dialog = new FileDialog(getFrame(), "Load... ", FileDialog.LOAD);
dialog.show();
String fileName = dialog.getFile();
String directory = dialog.getDirectory();
if (fileName != null) {
openCollection(new File(directory, fileName));
}
}
代码示例来源:origin: org.w3c.jigsaw/jigsaw
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command != null) {
if (command.equals("select")) {
FileDialog fileD = new FileDialog(new Frame(),
"Select a file");
//FIXME
String file = getFile();
String dir = null;
if (file != null) {
dir = new File(file).getParent();
fileD.setDirectory(dir);
}
fileD.show();
file = fileD.getFile();
dir = fileD.getDirectory();
String selected = null;
if ((file != null) && (file.length() > 0)) {
selected = (new File(dir, file)).getAbsolutePath();
setFile(selected);
}
}
}
}
代码示例来源:origin: ThomasFooteDQ/DroidQuest
@Override
protected boolean handleSaveSmallChip() {
if (carrying != null) {
if (carrying instanceof SmallChip) {
FileDialog fd = new FileDialog(level.roomdisplay.dq, "Save Chip", FileDialog.SAVE);
fd.setDirectory("chips");
fd.show();
System.out.println("Dialog returned with "
+ fd.getDirectory()
+ fd.getFile());
if (fd.getFile() != null) {
((SmallChip) carrying).SaveChip(fd.getDirectory() + fd.getFile());
}
return true;
}
}
return false;
}
代码示例来源:origin: ThomasFooteDQ/DroidQuest
public boolean handleLoadSmallChip() {
if (carrying != null) {
if (carrying instanceof SmallChip) {
FileDialog fd = new FileDialog(level.roomdisplay.dq, "Load Chip", FileDialog.LOAD);
fd.setDirectory("chips");
fd.show();
System.out.println("Dialog returned with "
+ fd.getDirectory()
+ fd.getFile());
if (fd.getFile() != null) {
((SmallChip) carrying).Empty();
((SmallChip) carrying).LoadChip(fd.getDirectory() + fd.getFile());
}
return true;
}
}
return false;
}
代码示例来源:origin: net.imagej/ij
fd.show();
name = fd.getFile();
String origName = name;
代码示例来源:origin: imagej/ImageJA
fd.show();
name = fd.getFile();
String origName = name;
代码示例来源:origin: net.imagej/ij
void open(String title, String path, String fileName) {
Frame parent = IJ.getInstance();
if (parent==null) {
if (sharedFrame==null) sharedFrame = new Frame();
parent = sharedFrame;
}
if (IJ.isMacOSX() && IJ.isJava18()) {
ImageJ ij = IJ.getInstance();
if (ij!=null && ij.isActive())
parent = ij;
else
parent = null;
}
FileDialog fd = new FileDialog(parent, title);
if (path!=null)
fd.setDirectory(path);
if (fileName!=null)
fd.setFile(fileName);
//GUI.center(fd);
fd.show();
name = fd.getFile();
if (name==null) {
if (IJ.isMacOSX())
System.setProperty("apple.awt.fileDialogForDirectories", "false");
Macro.abort();
} else
dir = fd.getDirectory();
}
代码示例来源:origin: imagej/ImageJA
void open(String title, String path, String fileName) {
Frame parent = IJ.getInstance();
if (parent==null) {
if (sharedFrame==null) sharedFrame = new Frame();
parent = sharedFrame;
}
if (IJ.isMacOSX() && IJ.isJava18()) {
ImageJ ij = IJ.getInstance();
if (ij!=null && ij.isActive())
parent = ij;
else
parent = null;
}
FileDialog fd = new FileDialog(parent, title);
if (path!=null)
fd.setDirectory(path);
if (fileName!=null)
fd.setFile(fileName);
//GUI.center(fd);
fd.show();
name = fd.getFile();
if (name==null) {
if (IJ.isMacOSX())
System.setProperty("apple.awt.fileDialogForDirectories", "false");
Macro.abort();
} else
dir = fd.getDirectory();
}
内容来源于网络,如有侵权,请联系作者删除!