本文整理汇总了Java中java.awt.FileDialog.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Java FileDialog.setTitle方法的具体用法?Java FileDialog.setTitle怎么用?Java FileDialog.setTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.FileDialog
的用法示例。
在下文中一共展示了FileDialog.setTitle方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFileDialog
import java.awt.FileDialog; //导入方法依赖的package包/类
private FileDialog createFileDialog( File currentDirectory ) {
if( badger != null )
return null;
if( !Boolean.getBoolean("nb.native.filechooser") )
return null;
if( dirsOnly && !BaseUtilities.isMac() )
return null;
Component parentComponent = findDialogParent();
Frame parentFrame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parentComponent);
FileDialog fileDialog = new FileDialog(parentFrame);
if (title != null) {
fileDialog.setTitle(title);
}
if( null != currentDirectory )
fileDialog.setDirectory(currentDirectory.getAbsolutePath());
return fileDialog;
}
示例2: 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);
}
示例3: chooseFile
import java.awt.FileDialog; //导入方法依赖的package包/类
private File chooseFile() {
JFrame mainFrame = (JFrame) WindowManager.getDefault().getMainWindow();
FileDialog fileDialog = new FileDialog(mainFrame, new File(System.getProperty("user.home")).toString());
fileDialog.setTitle("Export changes in cvs file");
fileDialog.setFile("expected.csv");
fileDialog.setMode(FileDialog.SAVE);
fileDialog.setFilenameFilter(new ExtFileFilter("csv"));
fileDialog.setVisible(true);
String filename = fileDialog.getFile();
if (filename == null){
return null;
}
String dir = fileDialog.getDirectory();
return new File(dir + File.separator + filename);
}
示例4: actionPerformed
import java.awt.FileDialog; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
// checkAndApplyChange();
if (e.getSource() == loadButton) {
FileDialog c = TextureEditor.INSTANCE.m_TextureFileChooser_SaveLoadImage;
c.setTitle("Open image ...");
c.setVisible(true);
if (c.getFile() != null) {
String name = TextureEditor.getFullPath(c);
setFileName(name);
}
} else if (e.getSource() == reloadButton) {
param.reloadeImage();
}
}
示例5: actionPerformed
import java.awt.FileDialog; //导入方法依赖的package包/类
/**
* {@inheritDoc} Displays a file chooser dialog
* and opens the selected files.
*/
@Override
public void actionPerformed(ActionEvent e) {
if (running) {
return;
}
try {
running = true;
JFileChooser chooser = prepareFileChooser();
File[] files;
try {
if( Boolean.getBoolean("nb.native.filechooser") ) { //NOI18N
String oldFileDialogProp = System.getProperty("apple.awt.fileDialogForDirectories"); //NOI18N
System.setProperty("apple.awt.fileDialogForDirectories", "false"); //NOI18N
FileDialog fileDialog = new FileDialog(WindowManager.getDefault().getMainWindow());
fileDialog.setMode(FileDialog.LOAD);
fileDialog.setDirectory(getCurrentDirectory().getAbsolutePath());
fileDialog.setTitle(chooser.getDialogTitle());
fileDialog.setVisible(true);
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() );
files = new File[] { new File( dir, selFile ) };
currentDirectory = dir;
} else {
throw new UserCancelException();
}
} else {
files = chooseFilesToOpen(chooser);
currentDirectory = chooser.getCurrentDirectory();
if (chooser.getFileFilter() != null) { // #227187
currentFileFilter =
chooser.getFileFilter().getDescription();
}
}
} catch (UserCancelException ex) {
return;
}
for (int i = 0; i < files.length; i++) {
OpenFile.openFile(files[i], -1);
}
} finally {
running = false;
}
}
示例6: showFileDialog
import java.awt.FileDialog; //导入方法依赖的package包/类
/**
* Displays an AWT open file dialog.
*/
private String showFileDialog(View parentView, String dialogTitle, final ContentType contentType, String path,
boolean save)
{
FileDialog fileDialog = new FileDialog(JOptionPane.getFrameForComponent((JComponent) parentView));
// Set selected file
if (save && path != null)
{
fileDialog.setFile(new File(path).getName());
}
// Set supported files filter
fileDialog.setFilenameFilter(new FilenameFilter()
{
public boolean accept(File dir, String name)
{
return isAcceptable(new File(dir, name).toString(), contentType);
}
});
// Update directory
File directory = getLastDirectory(contentType);
if (directory != null && directory.exists())
{
if (isDirectory(contentType))
{
fileDialog.setDirectory(directory.getParent());
fileDialog.setFile(directory.getName());
}
else
{
fileDialog.setDirectory(directory.toString());
}
}
if (save)
{
fileDialog.setMode(FileDialog.SAVE);
}
else
{
fileDialog.setMode(FileDialog.LOAD);
}
if (dialogTitle == null)
{
dialogTitle = getFileDialogTitle(save);
}
fileDialog.setTitle(dialogTitle);
fileDialog.setVisible(true);
String selectedFile = fileDialog.getFile();
// If user chose a file
if (selectedFile != null)
{
selectedFile = new File(fileDialog.getDirectory(), selectedFile).toString();
// Retrieve directory for future calls
if (isDirectory(contentType))
{
directory = new File(selectedFile);
}
else
{
directory = new File(fileDialog.getDirectory());
}
// Store current directory
setLastDirectory(contentType, directory);
// Return selected file
return selectedFile;
}
else
{
return null;
}
}
示例7: exportButtonActionPerformed
import java.awt.FileDialog; //导入方法依赖的package包/类
private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed
File saveFile = null;
String contents;
String path;
// JFileChooser chooser = new JFileChooser(lastPath);
//
// chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
// chooser.setDialogTitle("Select a name to export the file");
//
// CSVFileFilter filter = new CSVFileFilter();
// filter.addExtension("csv");
// filter.setFilterName("CSV Files");
// chooser.setFileFilter(filter);
// chooser.setAcceptAllFileFilterUsed(true);
//
// int returnVal = chooser.showSaveDialog(this);
// if (returnVal == JFileChooser.APPROVE_OPTION) {
// saveFile = chooser.getSelectedFile();
// lastPath=chooser.getSelectedFile().getParent();
// } else {
// return;
// }
FileDialog chooser2 = new FileDialog(this,lastPath,FileDialog.SAVE);
chooser2.setTitle("Select a name to export the file");
chooser2.setFilenameFilter(new FilenameFilter() {
@Override public boolean accept(File dir, String name) {
return name.endsWith(".csv");
}
});
chooser2.setMultipleMode(false);
chooser2.setVisible(true);
if(chooser2.getFile() != null){
saveFile = new File(chooser2.getDirectory()+chooser2.getFile());
lastPath=saveFile.getParent();
}else return;
try {
path = saveFile.getCanonicalPath();
} catch (IOException ex) {
JOptionPane.showMessageDialog(this, "Error exporting data:\n" + ex.getLocalizedMessage(), "Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (!path.endsWith(".csv")) {
path += ".csv";
}
contents = model.generateCSVOutput();
Files.writeFile(path, contents);
JOptionPane.showMessageDialog(this, "Data succesfully exported to " + path + " file.", "Export data", JOptionPane.INFORMATION_MESSAGE);
}