本文整理了Java中javax.swing.JFileChooser.setApproveButtonText()
方法的一些代码示例,展示了JFileChooser.setApproveButtonText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFileChooser.setApproveButtonText()
方法的具体详情如下:
包路径:javax.swing.JFileChooser
类名称:JFileChooser
方法名:setApproveButtonText
暂无
代码示例来源:origin: stanfordnlp/CoreNLP
private void doLoadFiles() {
if (chooser == null) {
chooser = createFileChooser();
}
String approveText = chooser.getApproveButtonText();
chooser.setApproveButtonText("Load with file filters");
int status = chooser.showOpenDialog(this);
chooser.setApproveButtonText(approveText);
if (status == JFileChooser.APPROVE_OPTION) {
//now set up the file filters if there are directories
File[] selectedFiles = chooser.getSelectedFiles();
boolean haveDirectory = false;
for (File f : selectedFiles) {
if (f.isDirectory()) {
haveDirectory = true;
break;
}
}
if (haveDirectory) {
doFileFilters(selectedFiles);
} else {
startFileLoadingThread(new EnumMap<>(FilterType.class), selectedFiles);
}
}
}
代码示例来源:origin: SonarSource/sonarqube
private void loadReport() {
final JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Choose scanner report directory");
File lastReport = getLastUsedReport();
if (lastReport != null) {
fc.setCurrentDirectory(lastReport);
}
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setFileHidingEnabled(false);
fc.setApproveButtonText("Open scanner report");
int returnVal = fc.showOpenDialog(frame);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
try {
setLastUsedReport(file);
loadReport(file);
} catch (Exception e) {
JOptionPane.showMessageDialog(frame, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
exit();
}
} else {
exit();
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
chooser.setApproveButtonText(approveText);
代码示例来源:origin: org.netbeans.api/org-openide-util
) {
if (approveButtonText != null) {
chooser.setApproveButtonText(approveButtonText);
chooser.setDialogType(javax.swing.JFileChooser.CUSTOM_DIALOG);
代码示例来源: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: org.netbeans.api/org-openide-util-ui
) {
if (approveButtonText != null) {
chooser.setApproveButtonText(approveButtonText);
chooser.setDialogType(javax.swing.JFileChooser.CUSTOM_DIALOG);
代码示例来源:origin: lbalazscs/Pixelitor
private JFileChooser createChooserForDirectorySelection() {
JFileChooser chooser;
chooser = new JFileChooser(nameTF.getText());
chooser.setApproveButtonText("Select Folder");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
return chooser;
}
代码示例来源:origin: stackoverflow.com
JFileChooser chooser = new JFileChooser();
chooser.setApproveButtonText("Save");
int result = chooser.showOpenDialog(null);
if(result == JFileChooser.APPROVE_OPTION){
File selection = chooser.getSelectedFile();
//verify if file exists
if(selection.exists()){
//you can continue the code here or call the next method or just use !exists and behavior for wrong file
}else{
//System.exit(0), show alert.. etc
}
}
代码示例来源:origin: stackoverflow.com
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setDialogTitle("Select a folder");
fc.setApproveButtonText(SELECT);
if(fc.showOpenDialog(singleton) == JFileChooser.APPROVE_OPTION) {
File folder = fc.getSelectedFile();
String path = folder.getPath() + File.separatorChar + "MYAPPFOLDER";
}
代码示例来源:origin: sensepost/yeti
public static String openFile(String fileExtension) {
JFileChooser dlgFile = new JFileChooser();
dlgFile.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
dlgFile.setApproveButtonText("Open");
int returnVal = dlgFile.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = dlgFile.getSelectedFile();
return file.getAbsolutePath();
}
return "";
}
代码示例来源:origin: raydac/netbeans-mmd-plugin
private void buttonGraphvizDotFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonGraphvizDotFileActionPerformed
final JFileChooser fileChooser = new JFileChooser(this.textFieldPathToGraphvizDot.getText());
fileChooser.setDialogTitle("Select GraphViz dot executable file");
fileChooser.setApproveButtonText("Select");
fileChooser.setAcceptAllFileFilterUsed(true);
fileChooser.setMultiSelectionEnabled(false);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
final File file = fileChooser.getSelectedFile();
this.textFieldPathToGraphvizDot.setText(file.getAbsolutePath());
}
}//GEN-LAST:event_buttonGraphvizDotFileActionPerformed
代码示例来源:origin: com.google.code.findbugs/findbugs
@Override
public void actionPerformed(ActionEvent evt) {
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setMultiSelectionEnabled(true);
chooser.setApproveButtonText("Choose");
chooser.setDialogTitle("Choose the directory");
if (chooser.showOpenDialog(SourceDirectoryWizard.this) == JFileChooser.APPROVE_OPTION) {
File[] selectedFiles = chooser.getSelectedFiles();
for (File selectedFile : selectedFiles) {
sourceRootBox.setText(selectedFile.getAbsolutePath());
}
nextButton.setEnabled(!"".equals(sourceRootBox.getText()));
}
}
});
代码示例来源:origin: net.java.dev.jets3t/jets3t
private File fileChooser(String title, JFrame frame, boolean dirOnly) {
// Prompt user to choose their Cockpit home directory.
JFileChooser fileChooser = new JFileChooser();
fileChooser.setAcceptAllFileFilterUsed(true);
fileChooser.setDialogTitle(title);
fileChooser.setFileSelectionMode(
(dirOnly ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_ONLY));
fileChooser.setApproveButtonText("Select " +
(dirOnly ? "Directory" : "File"));
int returnVal = fileChooser.showOpenDialog(frame);
if (returnVal != JFileChooser.APPROVE_OPTION) {
return null;
} else {
return fileChooser.getSelectedFile();
}
}
代码示例来源:origin: info.aduna.clustermap/aduna-clustermap-core
private void browse() {
if (fileChooser == null) {
fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setApproveButtonText("Select");
fileChooser.setDialogTitle("Select a directory");
fileChooser.setSelectedFile(new File(directoryField.getText()));
}
fileChooser.setCurrentDirectory(new File(directoryField.getText()));
int value = fileChooser.showDialog(this, null);
if (value == JFileChooser.APPROVE_OPTION) {
directoryField.setText(fileChooser.getSelectedFile().getPath());
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jets3t
private File fileChooser(String title, JFrame frame, boolean dirOnly) {
// Prompt user to choose their Cockpit home directory.
JFileChooser fileChooser = new JFileChooser();
fileChooser.setAcceptAllFileFilterUsed(true);
fileChooser.setDialogTitle(title);
fileChooser.setFileSelectionMode(
(dirOnly ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_ONLY));
fileChooser.setApproveButtonText("Select " +
(dirOnly ? "Directory" : "File"));
int returnVal = fileChooser.showOpenDialog(frame);
if (returnVal != JFileChooser.APPROVE_OPTION) {
return null;
} else {
return fileChooser.getSelectedFile();
}
}
代码示例来源:origin: info.aduna.clustermap/aduna-clustermap-core
public void actionPerformed(ActionEvent e) {
// lazily create the file chooser
if (fileChooser == null) {
fileChooser = new JFileChooser();
fileChooser.setApproveButtonText("Select");
fileChooser.setDialogTitle("Select a PNG file");
fileChooser.addChoosableFileFilter(new PngFileFilter());
fileChooser.setSelectedFile(new File(fileNameField.getText()));
}
// select a File
int value = fileChooser.showDialog(this, null);
if (value == JFileChooser.APPROVE_OPTION) {
fileNameField.setText(fileChooser.getSelectedFile().getPath());
}
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jets3t
private void chooseFolder() {
// Prompt user to choose their Cockpit home directory.
JFileChooser fileChooser = new JFileChooser();
fileChooser.setAcceptAllFileFilterUsed(true);
fileChooser.setDialogTitle("Choose Cockpit Home Folder");
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setApproveButtonText("Choose Folder");
fileChooser.setCurrentDirectory(cockpitHomeFolder);
int returnVal = fileChooser.showOpenDialog(ownerFrame);
if (returnVal != JFileChooser.APPROVE_OPTION) {
return;
} else {
this.cockpitHomeFolder = fileChooser.getSelectedFile();
this.folderPathTextField.setText(this.cockpitHomeFolder.getAbsolutePath());
refreshStoredCredentialsTable();
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-clientproject
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle(Bundle.CreateSiteTemplate_FileChooser());
chooser.setMultiSelectionEnabled(false);
chooser.setApproveButtonText(Bundle.CreateSiteTemplate_FileChooserButton());
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (chooser.showDialog(this, null) == JFileChooser.APPROVE_OPTION) {
File f = chooser.getSelectedFile();
if (f.isFile()) {
f = f.getParentFile();
}
fileTextField.setText(f.getAbsolutePath());
}
}//GEN-LAST:event_browseButtonActionPerformed
代码示例来源:origin: psidev.psi.mi/psimitab
public void actionPerformed( ActionEvent e ) {
JFileChooser chooser = new JFileChooser();
chooser.setApproveButtonText( "Convert to MITAB25" );
// Enable multiple selections
chooser.setMultiSelectionEnabled( true );
// Show the dialog; wait until dialog is closed
chooser.showOpenDialog( frame );
// Retrieve the selected files. This method returns empty
// if multiple-selection mode is not enabled.
File[] files = chooser.getSelectedFiles();
if ( files != null && files.length > 0 ) {
FilesProcessor processor = new FilesProcessor();
processor.process( frame, files, expansionStrategy, postProcessorStrategy, aggregateSelectedFiles );
}
}
} );
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-profiler
private JFileChooser getFileChooser() {
if (fileChooser == null) {
// File chooser
fileChooser = new JFileChooser();
fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
fileChooser.setMultiSelectionEnabled(false);
fileChooser.setDialogTitle(Bundle.ExportAction_ExportDialogTitle());
fileChooser.setApproveButtonText(Bundle.ExportAction_ExportDialogButton());
}
fileChooser.resetChoosableFileFilters();
setFilters();
return fileChooser;
}
内容来源于网络,如有侵权,请联系作者删除!