本文整理了Java中javax.swing.JFileChooser.setDialogTitle()
方法的一些代码示例,展示了JFileChooser.setDialogTitle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFileChooser.setDialogTitle()
方法的具体详情如下:
包路径:javax.swing.JFileChooser
类名称:JFileChooser
方法名:setDialogTitle
暂无
代码示例来源:origin: stanfordnlp/CoreNLP
private void browseFiles() {
jfc.setDialogTitle("Open file");
int status = jfc.showOpenDialog(this);
if (status == JFileChooser.APPROVE_OPTION) {
urlTextField.setText(jfc.getSelectedFile().getPath());
openButton.setEnabled(true);
}
}
代码示例来源:origin: bonnyfone/vectalign
private File showOpenDir(String title, File lastFile){
final JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setDialogTitle(title);
if(lastFile != null)
fc.setSelectedFile(lastFile);
fc.setFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
if (f.isDirectory())
return true;
return false;
}
@Override
public String getDescription() {
return "Directory";
}
});
int returnVal = fc.showOpenDialog(null);
File file = null;
if(returnVal == JFileChooser.APPROVE_OPTION)
file = fc.getSelectedFile();
return file;
}
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Opens a dialog and saves the output of the parser on the current
* text. If there is no current text, yell at the user and make
* them feel bad instead.
*/
public void saveOutput() {
if (textPane.getText().trim().length() == 0) {
JOptionPane.showMessageDialog(this, "No text to parse ", null,
JOptionPane.ERROR_MESSAGE);
return;
}
jfc.setDialogTitle("Save file");
int status = jfc.showSaveDialog(this);
if (status == JFileChooser.APPROVE_OPTION) {
saveOutput(jfc.getSelectedFile().getPath());
}
}
代码示例来源:origin: JGillam/burp-co2
File chooseFile(Component parentComponent, String defaultName, String title) {
final JFileChooser fc = new JFileChooser();
fc.setDialogTitle(title);
fc.setSelectedFile(new File(defaultName));
int returnVal = fc.showSaveDialog(parentComponent);
if (returnVal == JFileChooser.APPROVE_OPTION) {
return fc.getSelectedFile();
} else {
return null;
}
}
}
代码示例来源:origin: ron190/jsql-injection
final JFileChooser importFileDialog = new JFileChooser(PreferencesUtil.getPathFile());
importFileDialog.setDialogTitle(I18n.valueByKey("LIST_IMPORT_CONFIRM_TITLE"));
importFileDialog.setMultiSelectionEnabled(true);
choice = importFileDialog.showOpenDialog(this.dndList.getTopLevelAncestor());
} catch (ClassCastException | NullPointerException e) {
LOGGER.error(e, e);
代码示例来源:origin: stackoverflow.com
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"JPG & GIF Images", "jpg", "gif");
chooser.setFileFilter(filter);
chooser.setDialogTitle("Add new file");
int returnVal = chooser.showOpenDialog(parent);
代码示例来源:origin: stackoverflow.com
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("."));
chooser.setDialogTitle("select folder");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setAcceptAllFileFilterUsed(false);
代码示例来源:origin: chewiebug/GCViewer
public Export(final GCViewerGui gcViewer) {
this.gcViewer = gcViewer;
putValue(NAME, LocalisationHelper.getString("main_frame_menuitem_export"));
putValue(MNEMONIC_KEY, new Integer(LocalisationHelper.getString("main_frame_menuitem_mnemonic_export").charAt(0)));
putValue(SHORT_DESCRIPTION, LocalisationHelper.getString("main_frame_menuitem_hint_export"));
putValue(ACTION_COMMAND_KEY, ActionCommands.EXPORT.toString());
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('E', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() ));
putValue(SMALL_ICON, ImageHelper.loadImageIcon("save.png"));
setEnabled(false);
saveDialog = new JFileChooser();
saveDialog.setDialogTitle(LocalisationHelper.getString("fileexport_dialog_title"));
saveDialog.removeChoosableFileFilter(saveDialog.getAcceptAllFileFilter());
for (ExportExtensionFileFilter filter : ExportExtensionFileFilter.EXT_FILE_FILTERS) {
saveDialog.addChoosableFileFilter(filter);
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
private void prepareFileChooser(JFileChooser chooser) {
chooser.setFileSelectionMode(dirsOnly ? JFileChooser.DIRECTORIES_ONLY
: filesOnly ? JFileChooser.FILES_ONLY :
JFileChooser.FILES_AND_DIRECTORIES);
chooser.setAcceptAllFileFilterUsed(useAcceptAllFileFilter);
if (title != null) {
chooser.setDialogTitle(title);
代码示例来源:origin: bonnyfone/vectalign
private File showOpenFile(String title, File lastFile){
final JFileChooser fc = new JFileChooser();
fc.setDialogTitle(title);
if(lastFile != null)
fc.setSelectedFile(lastFile);
fc.setFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
if (f.isDirectory())
return true;
String extension = Utils.getExtension(f);
if (extension != null) {
if (extension.equals("svg"))
return true;
else
return false;
}
return false;
}
@Override
public String getDescription() {
return "SVG images";
}
});
int returnVal = fc.showOpenDialog(null);
File file = null;
if(returnVal == JFileChooser.APPROVE_OPTION)
file = fc.getSelectedFile();
return file;
}
代码示例来源:origin: cmusphinx/sphinx4
static public void getFilename(String title, int type) {
int returnVal;
fileChooser.setDialogTitle(title);
fileChooser.setCurrentDirectory(file);
fileChooser.setDialogType(type);
if (type == JFileChooser.OPEN_DIALOG) {
returnVal = fileChooser.showOpenDialog(jframe);
} else {
returnVal = fileChooser.showSaveDialog(jframe);
}
if (returnVal == JFileChooser.APPROVE_OPTION) {
file = fileChooser.getSelectedFile();
filename = file.getAbsolutePath();
prefs.put(FILENAME_PREFERENCE, filename);
}
}
代码示例来源:origin: stackoverflow.com
JFrame parentFrame = new JFrame();
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Specify a file to save");
int userSelection = fileChooser.showSaveDialog(parentFrame);
if (userSelection == JFileChooser.APPROVE_OPTION) {
File fileToSave = fileChooser.getSelectedFile();
System.out.println("Save as file: " + fileToSave.getAbsolutePath());
}
代码示例来源:origin: org.cytoscape/ding-customgraphics-manager-impl
private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {
// Add a directory
final JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Select Image Directory");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setMultiSelectionEnabled(true);
int returnVal = chooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION)
importFromDirectories(chooser.getSelectedFiles());
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-profiler
private static JFileChooser getSnapshotDirectoryChooser() {
if (snapshotDirectoryChooser == null) {
snapshotDirectoryChooser = new JFileChooser();
snapshotDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
snapshotDirectoryChooser.setMultiSelectionEnabled(false);
snapshotDirectoryChooser.setDialogType(JFileChooser.OPEN_DIALOG);
snapshotDirectoryChooser.setDialogTitle(Bundle.HeapDumpAction_DirectoryDialogCaption());
}
return snapshotDirectoryChooser;
}
代码示例来源:origin: locationtech/jts
private void initFileChoosers() {
if (pngFileChooser == null) {
pngFileChooser = new JFileChooser();
pngFileChooser.addChoosableFileFilter(SwingUtil.PNG_FILE_FILTER);
pngFileChooser.setDialogTitle("Save PNG");
pngFileChooser.setSelectedFile(new File("geoms.png"));
}
}
代码示例来源:origin: ron190/jsql-injection
importFileDialog.setDialogTitle(I18n.valueByKey("LIST_EXPORT_TITLE"));
int choice = importFileDialog.showSaveDialog(this.myList.getTopLevelAncestor());
if (choice != JFileChooser.APPROVE_OPTION) {
FileOutputStream file = new FileOutputStream(importFileDialog.getSelectedFile())
) {
PrintStream out = new PrintStream(file);
代码示例来源:origin: Nilhcem/FakeSMTP
/**
* Creates a {@code JFileChooser} component and sets it to be for directories only.
*
* @param parent the component from where the chooser will be launched <i>(should be the main panel of the application)</i>.
*/
public DirChooser(Component parent) {
this.parent = parent;
dirChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
dirChooser.setDialogTitle(String.format(I18n.INSTANCE.get("dirchooser.title"),
Configuration.INSTANCE.get("application.name")));
dirChooser.setApproveButtonText(I18n.INSTANCE.get("dirchooser.approve.btn"));
}
代码示例来源:origin: libgdx/libgdx
File getDirectory () {
if (System.getProperty("os.name").contains("Mac")) {
System.setProperty("apple.awt.fileDialogForDirectories", "true");
FileDialog dialog = new FileDialog(GdxSetupUI.this, "Choose destination", FileDialog.LOAD);
dialog.setVisible(true);
String name = dialog.getFile();
String dir = dialog.getDirectory();
if (name == null || dir == null) return null;
return new File(dialog.getDirectory(), dialog.getFile());
} else {
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setDialogTitle("Choose destination");
int result = chooser.showOpenDialog(null);
if (result == JFileChooser.APPROVE_OPTION) {
File dir = chooser.getSelectedFile();
if (dir == null) return null;
if (dir.getAbsolutePath().trim().length() == 0) return null;
return dir;
} else {
return null;
}
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Opens dialog to load a serialized parser
*/
public void loadParser() {
jfc.setDialogTitle("Load parser");
int status = jfc.showOpenDialog(this);
if (status == JFileChooser.APPROVE_OPTION) {
String filename = jfc.getSelectedFile().getPath();
if (filename.endsWith(".jar")) {
String model = chooseJarParser.show(filename, jfcLocation.location);
if (model != null) {
loadJarParser(filename, model);
}
} else {
loadParser(filename);
}
}
}
代码示例来源:origin: stackoverflow.com
JFrame parentFrame = new JFrame();
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Specify a file to save");
int userSelection = fileChooser.showSaveDialog(parentFrame);
if (userSelection == JFileChooser.APPROVE_OPTION) {
File fileToSave = fileChooser.getSelectedFile();
System.out.println("Save as file: " + fileToSave.getAbsolutePath());
}
内容来源于网络,如有侵权,请联系作者删除!