當前位置: 首頁>>代碼示例>>Java>>正文


Java FileDialog.setTitle方法代碼示例

本文整理匯總了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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:FileChooserBuilder.java

示例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);
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:17,代碼來源:ScreenCaptureDemo.java

示例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);
}
 
開發者ID:dbunibas,項目名稱:BART,代碼行數:16,代碼來源:Export.java

示例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();
	}
}
 
開發者ID:Erkaman,項目名稱:NeoTextureEdit2,代碼行數:15,代碼來源:ImageParameterEditor.java

示例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;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:55,代碼來源:OpenFileAction.java

示例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;
	}
}
 
開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:78,代碼來源:FileContentManager.java

示例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);
}
 
開發者ID:SCI2SUGR,項目名稱:KEEL,代碼行數:59,代碼來源:StatisticalF.java


注:本文中的java.awt.FileDialog.setTitle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。