本文整理汇总了Java中java.awt.FileDialog.getFiles方法的典型用法代码示例。如果您正苦于以下问题:Java FileDialog.getFiles方法的具体用法?Java FileDialog.getFiles怎么用?Java FileDialog.getFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.FileDialog
的用法示例。
在下文中一共展示了FileDialog.getFiles方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
}
}
示例2: 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 JsonFilenameFilter());
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.timeline.get(fileName.toURI());
}
}
}
示例3: 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);
}
}
示例4: saveDialog
import java.awt.FileDialog; //导入方法依赖的package包/类
void saveDialog(String text) {
try {
FileDialog fd = new FileDialog(visual.frame, text, FileDialog.SAVE);
fd.setFilenameFilter(sf.getSaveFilenameFilter());
fd.setVisible(true);
if (fd.getFiles().length == 0) {
return;
}
sf.save(fd.getFiles()[0], visual.getStichData());
} catch (Exception ex) {
JOptionPane.showMessageDialog(visual.frame, "error during save: " + ex.getMessage());
Logger
.getLogger(Visual.class
.getName()).log(Level.SEVERE, null, ex);
}
}
示例5: 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 JhvFilenameFilter());
fileDialog.setDirectory(JHVDirectory.STATES.getPath());
fileDialog.setVisible(true);
File[] fileNames = fileDialog.getFiles();
if (fileNames.length > 0 && fileNames[0].isFile())
Load.state.get(fileNames[0].toURI());
}
示例6: opendialog
import java.awt.FileDialog; //导入方法依赖的package包/类
public synchronized void opendialog() throws IOException {
FileDialog fd = new FileDialog(this, "open djvu file", FileDialog.LOAD);
fd.setMultipleMode(true);
fd.show();
if (fd.getDirectory() != null) {
File files[] = fd.getFiles();
for (File file : files) {
FileSavePath.save(file.getPath());
String url;
url = "" + file.toURI().toURL();
url = url.substring(5, url.length());
String name = file.getName();
if (!curropen.contains(name)) {
name_url.put(name, url);
url_name.put(url, name);
curropen.add(name);
bookList.add(url);
openBookInNewTab(url, name);
} else {
tabbedPane.setSelectedIndex(tabbedPane.indexOfTab(name));
}
}
} else {
}
}
示例7: loadItemActionPerformed
import java.awt.FileDialog; //导入方法依赖的package包/类
private void loadItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_loadItemActionPerformed
FileDialog fd = new FileDialog(this, "Choose a file", FileDialog.LOAD);
fd.setFile("*.xml");
fd.setVisible(true);
File[] files = fd.getFiles();
if (files.length > 0) {
File loadFile = files[0];
try {
ToolConfiguration currentToolConfig = new ToolConfiguration();
currentToolConfig.setAttackerConfig(controller.getAttackerConfig());
currentToolConfig.setAnalyzerConfig(controller.getAnalyzerConfig());
XmlPersistenceHelper.mergeConfigFileToConfigObject(loadFile, currentToolConfig);
} catch (XmlPersistenceError ex) {
Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
}
}
/*int returnVal = loadFileChooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File loadFile = loadFileChooser.getSelectedFile();
try {
XmlPersistenceHelper.mergeConfigFileToConfigObject(loadFile, controller.getConfig());
} catch (XmlPersistenceError ex) {
Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
}
}*/
}
示例8: chooseFile
import java.awt.FileDialog; //导入方法依赖的package包/类
@Override
public void chooseFile(final NativeFileChooserConfiguration configuration, NativeFileChooserCallback callback) {
NativeFileChooserUtils.checkNotNull(configuration, "configuration");
NativeFileChooserUtils.checkNotNull(callback, "callback");
// Create awt Dialog
FileDialog fileDialog = configuration.title == null ? new FileDialog((Frame) null)
: new FileDialog((Frame) null, configuration.title);
FilenameFilter filter = null;
// Add MIME type filter if any
if (configuration.mimeFilter != null)
filter = createMimeTypeFilter(configuration.mimeFilter);
// Add name filter if any
if (configuration.nameFilter != null) {
if (filter == null) {
filter = configuration.nameFilter;
} else {
// Combine filters!
final FilenameFilter mime = filter;
filter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return mime.accept(dir, name) && configuration.nameFilter.accept(dir, name);
}
};
}
}
if (filter != null)
fileDialog.setFilenameFilter(filter);
// Set starting path if any
if (configuration.directory != null)
fileDialog.setDirectory(configuration.directory.file().getAbsolutePath());
// Present it to the world
fileDialog.setVisible(true);
File[] files = fileDialog.getFiles();
if (files == null || files.length == 0) {
callback.onCancellation();
} else {
FileHandle result = null;
File f = files[0];
result = new FileHandle(f);
callback.onFileChosen(result);
}
}
示例9: images2djVuActionPerformed
import java.awt.FileDialog; //导入方法依赖的package包/类
private void images2djVuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_images2djVuActionPerformed
// TODO add your handling code here:
Djvust.setVisible(true);
FileDialog imagestoconvert2djvu = new FileDialog(new java.awt.Frame(), "Select Images", FileDialog.LOAD);
imagestoconvert2djvu.setMultipleMode(true);
imagestoconvert2djvu.setVisible(true);
String t = imagestoconvert2djvu.getDirectory();
openimgs = imagestoconvert2djvu.getDirectory();
boolean ch = true;
try {
if (t != null) {
imagess = imagestoconvert2djvu.getFiles();
imageNAME = new String[imagess.length];
for (int i = 0; i < imagess.length; i++) {
imageNAME[i] = imagess[i].getName();
System.out.println("Images name"+imageNAME[i].toString());
String sn = imageNAME[i].substring(imageNAME[i].lastIndexOf("."));
sn = sn.toLowerCase();
if (sn.equals(".jpg") | sn.equals(".jpeg") | sn.equals(".tif") | sn.equals(".png")) {
} else {
JOptionPane.showMessageDialog(null, "File selected not image\nPlease select image");
t = null;
ch = false;
break;
}
}
if (ch) {
FileDialog SaveDjVu = new FileDialog(new java.awt.Frame(), "Save DjVu", FileDialog.SAVE);
SaveDjVu.setVisible(true);
String djvu_path = SaveDjVu.getDirectory() + SaveDjVu.getFile();
String path ="/home/"+System.getProperty("user.name")+"/.Image2Djvu/output.pdf";
System.out.println("djvu_path :"+"/home/essam/Desktop/file");
System.out.println("System User Path"+path);
System.out.println("Openining images paths :it must have all images in a string :"+openimgs);
IMAGEStoPDF.convertToIMG(imageNAME, path, openimgs, 2);
System.out.println("Convert Images To Pdf OK ");
PDF2DjVu.PDF2DjVu( path, djvu_path, 2);
System.out.println("Convert Pdf To Djvu File Is Also Oka");
File open = new File(djvu_path + ".djvu");
String url;
url = "" + open.toURI();
url = url.substring(5, url.length());
String name = open.getName();
if (!curropen.contains(name)) {
name_url.put(name, url);
url_name.put(url, name);
curropen.add(name);
DjvuStart.unsavedbook.add(url);
DjvuStart.openBookInNewTab(url, name);
System.out.println("Book Opend Successfully");
} else if (curropen.contains(name)) {
tabbedPane.setSelectedIndex(tabbedPane.indexOfTab(name));
} else {
}
}
}
} catch (Exception e) {
} finally {
Djvust.setVisible(false);
File tf = new File("/home/"+System.getProperty("user.name")+"/.Image2Djvu/output.pdf");
if (tf.exists()) {
tf.delete();
}
}
}
示例10: pdfstatActionPerformed
import java.awt.FileDialog; //导入方法依赖的package包/类
private void pdfstatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pdfstatActionPerformed
// TODO add your handling code here:
Imagesstate.setVisible(true);
FileDialog openIMGS = new FileDialog(new java.awt.Frame(), "Select Images", FileDialog.LOAD);
openIMGS.setMultipleMode(true);
openIMGS.setVisible(true);
try {
openimg = openIMGS.getDirectory();
File files[] = openIMGS.getFiles();
imagesname = new String[files.length];
boolean ch = true;
if (openIMGS.getFile() != null) {
for (int i = 0; i < files.length; i++) {
imagesname[i] = files[i].getName();
//PDFFullPath = "C:\\DjVu++Task\\ImagestoPDF\\" + imagesname[i].substring(0, imagesname[i].lastIndexOf(".")) + ".pdf";
String sn = imagesname[i].substring(imagesname[i].lastIndexOf("."));
sn = sn.toLowerCase();
if (sn.equals(".jpg") | sn.equals(".jpeg") | sn.equals(".tif") | sn.equals(".png")) {
} else {
JOptionPane.showMessageDialog(null, "File is selected is not image\nPlease select image");
openimg = null;
ch = false;
break;
}
}
if (ch) {
FileDialog SaveDjVu = new FileDialog(new java.awt.Frame(), "Save Pdf", FileDialog.SAVE);
SaveDjVu.setVisible(true);
String path = SaveDjVu.getDirectory() + SaveDjVu.getFile();
if (path != null && SaveDjVu.getFile() != null) {
IMAGEStoPDF.convertToIMG(imagesname, path + ".pdf", openimg, 1);
}
}
} else {
Imagesstate.setVisible(false);
}
} catch (Exception t) {
} finally {
Imagesstate.setVisible(false);
}
}