本文整理汇总了Java中javax.swing.JFileChooser.setDialogTitle方法的典型用法代码示例。如果您正苦于以下问题:Java JFileChooser.setDialogTitle方法的具体用法?Java JFileChooser.setDialogTitle怎么用?Java JFileChooser.setDialogTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFileChooser
的用法示例。
在下文中一共展示了JFileChooser.setDialogTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doLoadGroundTruthFromTXT
import javax.swing.JFileChooser; //导入方法依赖的package包/类
synchronized public void doLoadGroundTruthFromTXT() {
JFileChooser c = new JFileChooser(gtFilename);
c.setDialogTitle("Choose ground truth bounding box file");
FileFilter filt = new FileNameExtensionFilter("TXT File", "txt");
c.addChoosableFileFilter(filt);
c.setFileFilter(filt);
c.setSelectedFile(new File(gtFilename));
int ret = c.showOpenDialog(chip.getAeViewer());
if (ret != JFileChooser.APPROVE_OPTION) {
return;
}
gtFilename = c.getSelectedFile().toString();
putString("GTFilename", gtFilename);
gtFilenameShort = gtFilename.substring(0, 5) + "..." + gtFilename.substring(gtFilename.lastIndexOf(File.separator));
try {
this.loadBoundingBoxes(c.getSelectedFile());
} catch (Exception ex) {
JOptionPane.showMessageDialog(chip.getAeViewer().getFilterFrame(), "Couldn't read bounding box file" + ex + ". See console for logging.", "Bad bounding box file", JOptionPane.WARNING_MESSAGE);
}
}
示例2: checkBrowser
import javax.swing.JFileChooser; //导入方法依赖的package包/类
public static boolean checkBrowser() {
AppList appList = MimeTypesList.getAppList();
String bpath = appList.getBrowserExec();
if (bpath != null)
if (new File(bpath).isFile())
return true;
JFileChooser chooser = new JFileChooser();
chooser.setFileHidingEnabled(false);
chooser.setDialogTitle(Local.getString("Select the web-browser executable"));
chooser.setAcceptAllFileFilterUsed(true);
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
/*java.io.File lastSel = (java.io.File) Context.get("LAST_SELECTED_RESOURCE_FILE");
if (lastSel != null)
chooser.setCurrentDirectory(lastSel);*/
if (chooser.showOpenDialog(App.getFrame()) != JFileChooser.APPROVE_OPTION)
return false;
appList.setBrowserExec(chooser.getSelectedFile().getPath());
CurrentStorage.get().storeMimeTypesList();
return true;
}
示例3: browseLocationAction
import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void browseLocationAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLocationAction
String command = evt.getActionCommand();
if ( "BROWSE".equals( command ) ) { // NOI18N
JFileChooser chooser = new JFileChooser ();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setDialogTitle(NbBundle.getMessage(PanelSourceFolders.class,"LBL_NWP1_SelectProjectLocation"));
chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
String path = this.projectLocationTextField.getText();
if (path.length() > 0) {
File f = new File (path);
if (f.exists ()) {
chooser.setSelectedFile(f);
}
}
if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { //NOI18N
File projectDir = chooser.getSelectedFile();
projectLocationTextField.setText( FileUtil.normalizeFile(projectDir).getAbsolutePath() );
}
panel.fireChangeEvent();
}
}
示例4: doSetPath
import javax.swing.JFileChooser; //导入方法依赖的package包/类
synchronized public void doSetPath() {
JFileChooser j = new JFileChooser();
j.setCurrentDirectory(new File(dirPath));
j.setApproveButtonText("Select");
j.setDialogTitle("Select a folder and base file name for calibration images");
j.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); // let user specify a base filename
int ret = j.showSaveDialog(null);
if (ret != JFileChooser.APPROVE_OPTION) {
return;
}
//imagesDirPath = j.getSelectedFile().getAbsolutePath();
dirPath = j.getCurrentDirectory().getPath();
fileBaseName = j.getSelectedFile().getName();
if (!fileBaseName.isEmpty()) {
fileBaseName = "-" + fileBaseName;
}
log.log(Level.INFO, "Changed images path to {0}", dirPath);
putString("dirPath", dirPath);
}
示例5: doSaveCalibration
import javax.swing.JFileChooser; //导入方法依赖的package包/类
synchronized public void doSaveCalibration() {
if (!calibrated) {
JOptionPane.showMessageDialog(null, "No calibration yet");
return;
}
JFileChooser j = new JFileChooser();
j.setCurrentDirectory(new File(dirPath));
j.setApproveButtonText("Select folder");
j.setDialogTitle("Select a folder to store calibration XML files");
j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // let user specify a base filename
int ret = j.showSaveDialog(null);
if (ret != JFileChooser.APPROVE_OPTION) {
return;
}
dirPath = j.getSelectedFile().getPath();
putString("dirPath", dirPath);
serializeMat(dirPath, "cameraMatrix", cameraMatrix);
serializeMat(dirPath, "distortionCoefs", distortionCoefs);
saved = true;
generateCalibrationString();
}
示例6: btnWorkDirActionPerformed
import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void btnWorkDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWorkDirActionPerformed
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(null);
chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
chooser.setMultiSelectionEnabled(false);
String workDir = txtWorkDir.getText();
if (workDir.equals("")) { //NOI18N
workDir = FileUtil.toFile(project.getProjectDirectory()).getAbsolutePath();
}
chooser.setSelectedFile(new File(workDir));
chooser.setDialogTitle(org.openide.util.NbBundle.getMessage(RunJarPanel.class, "TIT_SelectWorkingDirectory"));
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { //NOI18N
File file = FileUtil.normalizeFile(chooser.getSelectedFile());
txtWorkDir.setText(file.getAbsolutePath());
}
}
示例7: actionPerformed
import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Open file");
if (fc.showOpenDialog(observer) != JFileChooser.APPROVE_OPTION) {
return;
}
Path file = fc.getSelectedFile().toPath();
if (!Files.isReadable(file)) {
JOptionPane.showMessageDialog(observer,
lp.getString("readingError"), lp.getString("errorTitle"),
JOptionPane.ERROR_MESSAGE);
return;
}
JNotepadPPDocument openedDocument;
try {
openedDocument = new JNotepadPPDocument(observer, file);
} catch (IOException e1) {
observer.errorMessage(e1);
return;
}
int index = observer.getEditors().indexOf(openedDocument);
if (index > -1) {
observer.getTabs().setSelectedIndex(index);
return;
}
observer.addNewTab(openedDocument);
}
示例8: browseTemplate
import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void browseTemplate() {
JFileChooser chooser = new JFileChooser();
chooser.setFileHidingEnabled(false);
chooser.setDialogTitle(Local.getString("Select file"));
chooser.setAcceptAllFileFilterUsed(true);
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (templF.getText().length() >0)
chooser.setCurrentDirectory(new java.io.File(templF.getText()));
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
templF.setText(chooser.getSelectedFile().getPath());
}
示例9: ShowDlgSaveDiagrama
import javax.swing.JFileChooser; //导入方法依赖的package包/类
public static File ShowDlgSaveDiagrama(JComponent form, Diagrama diag) {
JFileChooser f = new JFileChooser();
//f.setDialogTitle(Editor.fromConfiguracao.getValor("Controler.dlg.modelo.salvar"));
f.setFileSelectionMode(JFileChooser.FILES_ONLY);
FileFilter filter = new FileNameExtensionFilter("BrModelo(bin)", Arquivo.brM3);
FileFilter filter2 = new FileNameExtensionFilter("BrModelo(xml)", Arquivo.xml);
f.addChoosableFileFilter(filter);
f.addChoosableFileFilter(filter2);
f.setAcceptAllFileFilterUsed(false);
f.setFileFilter(filter);
if (dir.isEmpty()) dir = System.getProperty("user.dir");
f.setCurrentDirectory(new File(dir + "."));
f.setDialogTitle(Editor.fromConfiguracao.getValor("Controler.MSG_SAVE_TITLE") + " " + diag.getNomeFormatado());
if (!diag.getNome().isEmpty()){
f.setSelectedFile(new File(diag.getNome()));
}
//f.setApproveButtonText(Editor.fromConfiguracao.getValor("Controler.dlg.modelo.salvar"));
int returnVal = f.showSaveDialog(form);
//int returnVal = f.showDialog(form, Editor.fromConfiguracao.getValor("Controler.dlg.modelo.salvar"));
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = f.getSelectedFile();
String ext = Arquivo.getExtension(file);
if (ext == null) {
ext = "";
}
String arq = file.getAbsolutePath();
dir = f.getCurrentDirectory().getAbsolutePath();
if (f.getFileFilter().equals(filter) && !Arquivo.brM3.toUpperCase().equals(ext.toUpperCase())) {
return new File(arq + "." + Arquivo.brM3);
}
if (f.getFileFilter().equals(filter2) && !Arquivo.xml.toUpperCase().equals(ext.toUpperCase())) {
return new File(arq + "." + Arquivo.xml);
}
return file;
} else {
return null;
}
}
示例10: selectAppBrowseB_actionPerformed
import javax.swing.JFileChooser; //导入方法依赖的package包/类
void selectAppBrowseB_actionPerformed(ActionEvent e) {
// Fix until Sun's JVM supports more locales...
UIManager.put("FileChooser.lookInLabelText", Local.getString("Look in:"));
UIManager.put("FileChooser.upFolderToolTipText", Local.getString("Up One Level"));
UIManager.put("FileChooser.newFolderToolTipText", Local.getString("Create New Folder"));
UIManager.put("FileChooser.listViewButtonToolTipText", Local.getString("List"));
UIManager.put("FileChooser.detailsViewButtonToolTipText", Local.getString("Details"));
UIManager.put("FileChooser.fileNameLabelText", Local.getString("File Name:"));
UIManager.put("FileChooser.filesOfTypeLabelText", Local.getString("Files of Type:"));
UIManager.put("FileChooser.openButtonText", Local.getString("Open"));
UIManager.put("FileChooser.openButtonToolTipText", Local.getString("Open selected file"));
UIManager.put("FileChooser.cancelButtonText", Local.getString("Cancel"));
UIManager.put("FileChooser.cancelButtonToolTipText", Local.getString("Cancel"));
UIManager.put("FileChooser.acceptAllFileFilterText", Local.getString("All Files") + " (*.*)");
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle(Local.getString("Path to executable"));
chooser.setFileHidingEnabled(false);
chooser.setAcceptAllFileFilterUsed(true);
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (System.getProperty("os.name").startsWith("Win")) {
chooser.setFileFilter(new AllFilesFilter(AllFilesFilter.EXE));
chooser.setCurrentDirectory(new File("C:\\Program Files"));
}
chooser.setPreferredSize(new Dimension(550, 375));
/*
java.io.File lastSel = (java.io.File) Context.get("LAST_SELECTED_IMPORT_FILE");
if (lastSel != null)
chooser.setCurrentDirectory(lastSel);
*/
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
applicationField.setText(chooser.getSelectedFile().getPath());
}
示例11: actionPerformed
import javax.swing.JFileChooser; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e){
JFileChooser fileChooser = MainFrame.getFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setDialogTitle("Select a directory for the index files");
int res = fileChooser.showOpenDialog(CreateIndexGUI.this);
if(res == JFileChooser.APPROVE_OPTION) indexLocationTextField.
setText(fileChooser.
getSelectedFile().toString());
}
示例12: getLayerSessionChooser
import javax.swing.JFileChooser; //导入方法依赖的package包/类
public static void getLayerSessionChooser() throws IOException{
JFileChooser sessionImport = new JFileChooser
(System.getProperty("user.home") + "/Desktop");
sessionImport.setDialogTitle("Import Layer Session");
sessionImport.setAcceptAllFileFilterUsed(true);
sessionImport.setFileFilter(new FileFilter() {
public boolean accept(File file) {
String fileName = file.getName().toLowerCase();
if (fileName.endsWith(".xml")) {
return true;
}
return false;
}
public String getDescription() {
return "XML file (*.xml)";
}
});
sessionImport.setFileSelectionMode(JFileChooser.FILES_ONLY);
int code = sessionImport.showOpenDialog(map.getParent());
if(code==JFileChooser.CANCEL_OPTION){
doImport = false;
return;
}else if(code==JFileChooser.APPROVE_OPTION){
File f =sessionImport.getSelectedFile();
String fs = f.toString();
importLayerSession(fs);
doImport = true;
}
}
示例13: select
import javax.swing.JFileChooser; //导入方法依赖的package包/类
private static boolean select(
final PathModel model,
final File[] currentDir,
final Component parentComponent) {
final JFileChooser chooser = new JFileChooser ();
chooser.setMultiSelectionEnabled (true);
String title = null;
String message = null;
String approveButtonName = null;
String approveButtonNameMne = null;
if (model.type == SOURCES) {
title = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenSources");
message = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_Sources");
approveButtonName = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenSources");
approveButtonNameMne = NbBundle.getMessage (J2SEPlatformCustomizer.class,"MNE_OpenSources");
} else if (model.type == JAVADOC) {
title = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenJavadoc");
message = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_Javadoc");
approveButtonName = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenJavadoc");
approveButtonNameMne = NbBundle.getMessage (J2SEPlatformCustomizer.class,"MNE_OpenJavadoc");
}
chooser.setDialogTitle(title);
chooser.setApproveButtonText(approveButtonName);
chooser.setApproveButtonMnemonic (approveButtonNameMne.charAt(0));
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
if (Utilities.isMac()) {
//New JDKs and JREs are bundled into package, allow JFileChooser to navigate in
chooser.putClientProperty("JFileChooser.packageIsTraversable", "always"); //NOI18N
}
//#61789 on old macosx (jdk 1.4.1) these two method need to be called in this order.
chooser.setAcceptAllFileFilterUsed( false );
chooser.setFileFilter (new ArchiveFileFilter(message,new String[] {"ZIP","JAR"})); //NOI18N
if (currentDir[0] != null) {
chooser.setCurrentDirectory(currentDir[0]);
}
if (chooser.showOpenDialog(parentComponent) == JFileChooser.APPROVE_OPTION) {
File[] fs = chooser.getSelectedFiles();
boolean addingFailed = false;
for (File f : fs) {
//XXX: JFileChooser workaround (JDK bug #5075580), double click on folder returns wrong file
// E.g. for /foo/src it returns /foo/src/src
// Try to convert it back by removing last invalid name component
if (!f.exists()) {
File parent = f.getParentFile();
if (parent != null && f.getName().equals(parent.getName()) && parent.exists()) {
f = parent;
}
}
if (f.exists()) {
addingFailed|=!model.addPath (f);
}
}
if (addingFailed) {
new NotifyDescriptor.Message (NbBundle.getMessage(J2SEPlatformCustomizer.class,"TXT_CanNotAddResolve"),
NotifyDescriptor.ERROR_MESSAGE);
}
currentDir[0] = FileUtil.normalizeFile(chooser.getCurrentDirectory());
return true;
}
return false;
}
示例14: setIconB_actionPerformed
import javax.swing.JFileChooser; //导入方法依赖的package包/类
void setIconB_actionPerformed(ActionEvent e) {
// Fix until Sun's JVM supports more locales...
UIManager.put("FileChooser.lookInLabelText", Local.getString("Look in:"));
UIManager.put("FileChooser.upFolderToolTipText", Local.getString("Up One Level"));
UIManager.put("FileChooser.newFolderToolTipText", Local.getString("Create New Folder"));
UIManager.put("FileChooser.listViewButtonToolTipText", Local.getString("List"));
UIManager.put("FileChooser.detailsViewButtonToolTipText", Local.getString("Details"));
UIManager.put("FileChooser.fileNameLabelText", Local.getString("File Name:"));
UIManager.put("FileChooser.filesOfTypeLabelText", Local.getString("Files of Type:"));
UIManager.put("FileChooser.openButtonText", Local.getString("Open"));
UIManager.put("FileChooser.openButtonToolTipText", Local.getString("Open selected file"));
UIManager.put("FileChooser.cancelButtonText", Local.getString("Cancel"));
UIManager.put("FileChooser.cancelButtonToolTipText", Local.getString("Cancel"));
UIManager.put("FileChooser.acceptAllFileFilterText", Local.getString("All Files") + " (*.*)");
JFileChooser chooser = new JFileChooser();
chooser.setPreferredSize(new Dimension(550, 375));
chooser.setFileHidingEnabled(false);
chooser.setDialogTitle(Local.getString("Choose icon file"));
//chooser.setAcceptAllFileFilterUsed(true);
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
chooser.setCurrentDirectory(
new File(net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/mimetypes").getPath()));
/*if (System.getProperty("os.name").startsWith("Win")) {
chooser.setFileFilter(new AllFilesFilter(AllFilesFilter.ICO));
chooser.setCurrentDirectory(new File("C:\\Program Files"));
}
else */
chooser.addChoosableFileFilter(new net.sf.memoranda.ui.htmleditor.filechooser.ImageFilter());
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
try {
iconLabel.setIcon(new ImageIcon(chooser.getSelectedFile().getPath()));
}
catch (Exception ex) {
//ex.printStackTrace();
}
finally {
iconPath = chooser.getSelectedFile().getPath();
}
}
}
示例15: getPatchFor
import javax.swing.JFileChooser; //导入方法依赖的package包/类
private File getPatchFor(FileObject fo) {
JFileChooser chooser = new JFileChooser();
String patchDirPath = DiffModuleConfig.getDefault().getPreferences().get(PREF_RECENT_PATCH_PATH, System.getProperty("user.home"));
File patchDir = new File(patchDirPath);
while (!patchDir.isDirectory()) {
patchDir = patchDir.getParentFile();
if (patchDir == null) {
patchDir = new File(System.getProperty("user.home"));
break;
}
}
FileUtil.preventFileChooserSymlinkTraversal(chooser, patchDir);
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
String title = NbBundle.getMessage(PatchAction.class,
(fo.isData()) ? "TITLE_SelectPatchForFile"
: "TITLE_SelectPatchForFolder", fo.getNameExt());
chooser.setDialogTitle(title);
// setup filters, default one filters patch files
FileFilter patchFilter = new javax.swing.filechooser.FileFilter() {
@Override
public boolean accept(File f) {
return f.getName().endsWith("diff") || f.getName().endsWith("patch") || f.isDirectory(); // NOI18N
}
@Override
public String getDescription() {
return NbBundle.getMessage(PatchAction.class, "CTL_PatchDialog_FileFilter");
}
};
chooser.addChoosableFileFilter(patchFilter);
chooser.setFileFilter(patchFilter);
chooser.setApproveButtonText(NbBundle.getMessage(PatchAction.class, "BTN_Patch"));
chooser.setApproveButtonMnemonic(NbBundle.getMessage(PatchAction.class, "BTN_Patch_mnc").charAt(0));
chooser.setApproveButtonToolTipText(NbBundle.getMessage(PatchAction.class, "BTN_Patch_tooltip"));
HelpCtx ctx = new HelpCtx(PatchAction.class.getName());
DialogDescriptor descriptor = new DialogDescriptor( chooser, title, true, new Object[0], null, 0, ctx, null );
final Dialog dialog = DialogDisplayer.getDefault().createDialog( descriptor );
dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PatchAction.class, "ACSD_PatchDialog"));
ChooserListener listener = new PatchAction.ChooserListener(dialog,chooser);
chooser.addActionListener(listener);
dialog.setVisible(true);
File selectedFile = listener.getFile();
if (selectedFile != null) {
DiffModuleConfig.getDefault().getPreferences().put(PREF_RECENT_PATCH_PATH, selectedFile.getParentFile().getAbsolutePath());
}
return selectedFile;
}