本文整理了Java中javax.swing.JFileChooser.getCurrentDirectory()
方法的一些代码示例,展示了JFileChooser.getCurrentDirectory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFileChooser.getCurrentDirectory()
方法的具体详情如下:
包路径:javax.swing.JFileChooser
类名称:JFileChooser
方法名:getCurrentDirectory
暂无
代码示例来源: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: org.netbeans.api/org-openide-filesystems
private void saveCurrentDir() {
File dir = super.getCurrentDirectory();
if (!DONT_STORE_DIRECTORIES && dir != null && dir.exists() && dir.isDirectory()) {
NbPreferences.forModule(FileChooserBuilder.class).put(dirKey, dir.getPath());
}
}
}
代码示例来源:origin: deathmarine/Luyten
private void saveOpenDialogDir(JFileChooser fc) {
try {
File currentDir = fc.getCurrentDirectory();
if (currentDir != null && currentDir.exists() && currentDir.isDirectory()) {
luytenPrefs.setFileOpenCurrentDirectory(currentDir.getAbsolutePath());
}
} catch (Exception e) {
Luyten.showExceptionDialog("Exception!", e);
}
}
代码示例来源:origin: deathmarine/Luyten
private void saveSaveDialogDir(JFileChooser fc) {
try {
File currentDir = fc.getCurrentDirectory();
if (currentDir != null && currentDir.exists() && currentDir.isDirectory()) {
luytenPrefs.setFileSaveCurrentDirectory(currentDir.getAbsolutePath());
}
} catch (Exception e) {
Luyten.showExceptionDialog("Exception!", e);
}
}
}
代码示例来源:origin: skylot/jadx
public void openFile() {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setAcceptAllFileFilterUsed(true);
String[] exts = {"apk", "dex", "jar", "class", "zip", "aar", "arsc"};
String description = "supported files: " + Arrays.toString(exts).replace('[', '(').replace(']', ')');
fileChooser.setFileFilter(new FileNameExtensionFilter(description, exts));
fileChooser.setToolTipText(NLS.str("file.open_action"));
String currentDirectory = settings.getLastOpenFilePath();
if (!currentDirectory.isEmpty()) {
fileChooser.setCurrentDirectory(new File(currentDirectory));
}
int ret = fileChooser.showDialog(mainPanel, NLS.str("file.open_title"));
if (ret == JFileChooser.APPROVE_OPTION) {
settings.setLastOpenFilePath(fileChooser.getCurrentDirectory().getPath());
openFile(fileChooser.getSelectedFile());
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
/**
* Show an open dialog with a file chooser set up according to the
* parameters of this builder.
* @return A file if the user clicks the accept button and a file or
* folder was selected at the time the user clicked cancel.
*/
public File showOpenDialog() {
JFileChooser chooser = createFileChooser();
if( Boolean.getBoolean("nb.native.filechooser") ) { //NOI18N
FileDialog fileDialog = createFileDialog( chooser.getCurrentDirectory() );
if( null != fileDialog ) {
return showFileDialog(fileDialog, FileDialog.LOAD );
}
}
chooser.setMultiSelectionEnabled(false);
int dlgResult = chooser.showOpenDialog(findDialogParent());
if (JFileChooser.APPROVE_OPTION == dlgResult) {
File result = chooser.getSelectedFile();
if (result != null && !result.exists()) {
result = null;
}
return result;
} else {
return null;
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
/**
* Show a save dialog with the file chooser set up according to the
* parameters of this builder.
* @return A file if the user clicks the accept button and a file or
* folder was selected at the time the user clicked cancel.
*/
public File showSaveDialog() {
JFileChooser chooser = createFileChooser();
if( Boolean.getBoolean("nb.native.filechooser") ) { //NOI18N
FileDialog fileDialog = createFileDialog( chooser.getCurrentDirectory() );
if( null != fileDialog ) {
return showFileDialog( fileDialog, FileDialog.SAVE );
}
}
int result = chooser.showSaveDialog(findDialogParent());
if (JFileChooser.APPROVE_OPTION == result) {
return chooser.getSelectedFile();
} else {
return null;
}
}
代码示例来源:origin: stackoverflow.com
+ chooser.getCurrentDirectory());
System.out.println("getSelectedFile() : "
+ chooser.getSelectedFile());
代码示例来源:origin: skylot/jadx
private void saveAll(boolean export) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setToolTipText(NLS.str("file.save_all_msg"));
String currentDirectory = settings.getLastSaveFilePath();
if (!currentDirectory.isEmpty()) {
fileChooser.setCurrentDirectory(new File(currentDirectory));
}
int ret = fileChooser.showDialog(mainPanel, NLS.str("file.select"));
if (ret == JFileChooser.APPROVE_OPTION) {
JadxArgs decompilerArgs = wrapper.getArgs();
decompilerArgs.setExportAsGradleProject(export);
if (export) {
decompilerArgs.setSkipSources(false);
decompilerArgs.setSkipResources(false);
} else {
decompilerArgs.setSkipSources(settings.isSkipSources());
decompilerArgs.setSkipResources(settings.isSkipResources());
}
settings.setLastSaveFilePath(fileChooser.getCurrentDirectory().getPath());
ProgressMonitor progressMonitor = new ProgressMonitor(mainPanel, NLS.str("msg.saving_sources"), "", 0, 100);
progressMonitor.setMillisToPopup(0);
wrapper.saveAll(fileChooser.getSelectedFile(), progressMonitor);
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
chooser.getCurrentDirectory());
代码示例来源:origin: stackoverflow.com
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("."));
chooser.setDialogTitle("choosertitle");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setAcceptAllFileFilterUsed(false);
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory());
System.out.println("getSelectedFile() : " + chooser.getSelectedFile());
} else {
System.out.println("No Selection ");
}
代码示例来源:origin: geotools/geotools
/**
* Displays a file chooser dialog and returns the selected file.
*
* @return the selected file
*/
static File getFile() {
JFileChooser chooser = new JFileChooser(cwd);
chooser.setFileFilter(
new FileFilter() {
@Override
public boolean accept(File f) {
return true;
}
@Override
public String getDescription() {
return "All files";
}
});
if (chooser.showSaveDialog(null) != JFileChooser.APPROVE_OPTION) {
return null;
}
cwd = chooser.getCurrentDirectory();
return chooser.getSelectedFile();
}
}
代码示例来源:origin: org.riedelcastro/whatswrong
/**
* gets the directory to use in the file dialog.
*
* @return the directory of the file dialog.
*/
public String getDirectory() {
return fileChooser.getCurrentDirectory().getPath();
}
代码示例来源:origin: stackoverflow.com
JFileChooser fc = new JFileChooser();
fc.showOpenDialog(null);
File selected = fc.getSelectedFile();
System.out.println("You selected " + selected);
File currentDirectory = fc.getCurrentDirectory();
// Hack alert
fc.setSelectedFile(new File(""));
fc.setCurrentDirectory(currentDirectory);
fc.showOpenDialog(null);
selected = fc.getSelectedFile();
System.out.println("You selected " + selected);
代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core
@Override
public void savePreferences() {
final File currentDirectory = this.fileChooser.getCurrentDirectory();
if (currentDirectory == null) {
return;
}
this.preferences.put("folder", currentDirectory.getAbsolutePath()); //$NON-NLS-1$
}
代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core
@Override
public void savePreferences() {
final File currentDirectory = this.fileChooser.getCurrentDirectory();
this.preferences.put("folder", currentDirectory.getAbsolutePath()); //$NON-NLS-1$
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
public void actionPerformed(final ActionEvent _ae) {
final String s = _f.getCurrentDirectory().getAbsolutePath();
if (!list_.contains(s)) {
model.addElement(s);
CtuluFavoriteFiles.this.fireChange();
}
}
});
代码示例来源:origin: com.l2fprod.common/l2fprod-common-directorychooser
public void rescanCurrentDirectory(JFileChooser fc) {
super.rescanCurrentDirectory(fc);
findFile(chooser.getSelectedFile() == null?chooser.getCurrentDirectory()
:chooser.getSelectedFile(), true, true);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
public DirectoryComboBoxModel()
{
// Add the current directory to the model, and make it the
// selectedDirectory
File dir= getFileChooser().getCurrentDirectory();
if (dir != null)
{
addItem(dir);
}
}
代码示例来源:origin: EvoSuite/evosuite
@Test
public void testGetCurrentDirectory(){
JFileChooser chooser = new MockJFileChooser();
File dir = chooser.getCurrentDirectory();
Assert.assertTrue(dir.exists());
Assert.assertTrue(dir instanceof MockFile);
}
内容来源于网络,如有侵权,请联系作者删除!