本文整理了Java中javax.swing.JFileChooser.setFileSelectionMode()
方法的一些代码示例,展示了JFileChooser.setFileSelectionMode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFileChooser.setFileSelectionMode()
方法的具体详情如下:
包路径:javax.swing.JFileChooser
类名称:JFileChooser
方法名:setFileSelectionMode
暂无
代码示例来源:origin: stackoverflow.com
final JFileChooser chooser = new JFileChooser() {
public void approveSelection() {
if (getSelectedFile().isFile()) {
return;
} else
super.approveSelection();
}
};
chooser.setFileSelectionMode( JFileChooser.FILES_AND_DIRECTORIES );
代码示例来源:origin: marytts/marytts
private void browseOutputDirActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_browseOutputDirActionPerformed
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
// System.out.println("Opening: " + file.getAbsolutePath());
tfOutputDir.setText(file.getAbsolutePath());
}
}// GEN-LAST:event_browseOutputDirActionPerformed
代码示例来源:origin: pmd/pmd
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser(rootDirectoryField.getText());
fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
fc.showDialog(frame, "Select");
if (fc.getSelectedFile() != null) {
rootDirectoryField.setText(fc.getSelectedFile().getAbsolutePath());
}
}
}
代码示例来源:origin: openmrs/openmrs-core
/**
* Do the stuff for this class (create the file)
*
* @throws Exception
*/
public static void main(String args[]) throws Exception {
System.out.println("Starting...");
String wd = "./test";
// choose the directory to open
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File(wd));
chooser.setMultiSelectionEnabled(true);
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int result = chooser.showOpenDialog(null);
if (result == JFileChooser.APPROVE_OPTION) {
File[] dirs = chooser.getSelectedFiles();
for (File directory : dirs) {
System.out.println("Doing migration on directory: " + directory.getAbsolutePath());
doMigration(directory);
}
}
}
代码示例来源:origin: cytoscape/application
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: stackoverflow.com
import java.io.File;
import javax.swing.JFileChooser;
public class ShowDirectoriesOnly {
public static void main(String[] args) {
JFileChooser fileChooser = new JFileChooser( "." );
fileChooser.setControlButtonsAreShown( false );
fileChooser.setFileFilter( new FolderFilter() );
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.showOpenDialog(null);
}
private static class FolderFilter extends javax.swing.filechooser.FileFilter {
@Override
public boolean accept( File file ) {
return file.isDirectory();
}
@Override
public String getDescription() {
return "We only take directories";
}
}
}
代码示例来源: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: marytts/marytts
private void browseInputDirActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_browseInputDirActionPerformed
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
// System.out.println("Opening: " + file.getAbsolutePath());
tfInputDir.setText(file.getAbsolutePath());
}
}// GEN-LAST:event_browseInputDirActionPerformed
代码示例来源:origin: osmdroid/osmdroid
@Override
public void actionPerformed(final ActionEvent e) {
final JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
jfc.setAcceptAllFileFilterUsed(false);
final int result = jfc.showSaveDialog(null);
if (result == JFileChooser.APPROVE_OPTION) {
txtTempFolder.setText(jfc.getSelectedFile().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: stackoverflow.com
JFileChooser j = new JFileChooser();
j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
Integer opt = j.showSaveDialog(this);
代码示例来源: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: marytts/marytts
private void browseSoxActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_browseSoxActionPerformed
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
// System.out.println("Opening: " + file.getAbsolutePath());
tfSoxPath.setText(file.getAbsolutePath());
}
}// GEN-LAST:event_browseSoxActionPerformed
代码示例来源:origin: stackoverflow.com
import javax.swing.*;
public class Example
{
public static void main(String[] args)
{
JFileChooser f = new JFileChooser();
f.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
f.showSaveDialog(null);
System.out.println(f.getCurrentDirectory());
System.out.println(f.getSelectedFile());
}
}
代码示例来源:origin: deathmarine/Luyten
private JFileChooser createFileChooser(String... fileFilters) {
JFileChooser fc = new JFileChooser();
for (String fileFilter : fileFilters) {
fc.addChoosableFileFilter(new FileChooserFileFilter(fileFilter));
}
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setMultiSelectionEnabled(false);
return fc;
}
代码示例来源:origin: marytts/marytts
private void browseSoxActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_browseSoxActionPerformed
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
// System.out.println("Opening: " + file.getAbsolutePath());
tfSoxPath.setText(file.getAbsolutePath());
}
}// GEN-LAST:event_browseSoxActionPerformed
代码示例来源:origin: osmdroid/osmdroid
@Override
public void actionPerformed(final ActionEvent e) {
final JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
jfc.setAcceptAllFileFilterUsed(true);
final int result = jfc.showSaveDialog(null);
if (result == JFileChooser.APPROVE_OPTION) {
final String absolutePath = jfc.getSelectedFile().getAbsolutePath();
if (absolutePath.endsWith(".zip")) {
txtDestination.setText(absolutePath);
} else {
txtDestination.setText(absolutePath + ".zip");
}
}
}
});
代码示例来源:origin: winder/Universal-G-Code-Sender
public static JFileChooser getSettingsFileChooser() {
FirmwareSettingsFileTypeFilter filter = new FirmwareSettingsFileTypeFilter();
// Setup file browser with the last path used.
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setFileHidingEnabled(true);
fileChooser.addChoosableFileFilter(filter);
fileChooser.setAcceptAllFileFilterUsed(true);
fileChooser.setFileFilter(filter);
return fileChooser;
}
代码示例来源:origin: marytts/marytts
private void browseInputDirActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_browseInputDirActionPerformed
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
// System.out.println("Opening: " + file.getAbsolutePath());
tfInputDir.setText(file.getAbsolutePath());
}
}// GEN-LAST:event_browseInputDirActionPerformed
代码示例来源:origin: marytts/marytts
private void jMenuItem_OpenActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jMenuItem_OpenActionPerformed
// Allow user to choose a different voice (prompt set) without exiting the tool
// Create a file chooser
final JFileChooser openDialog = new JFileChooser();
// Set the current directory to the voice currently in use
openDialog.setCurrentDirectory(getVoiceFolderPath());
openDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int result = openDialog.showDialog(AdminWindow.this, "Open Voice");
if (result == JFileChooser.APPROVE_OPTION) {
File voice = openDialog.getSelectedFile();
setVoiceFolderPath(voice); // Set to the selected the voice folder path
Test.output("Open voice: " + voice);
setupVoice();
} else {
Test.output("Open command cancelled.");
}
}// GEN-LAST:event_jMenuItem_OpenActionPerformed
内容来源于网络,如有侵权,请联系作者删除!