javax.swing.JFileChooser.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(179)

本文整理了Java中javax.swing.JFileChooser.<init>()方法的一些代码示例,展示了JFileChooser.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFileChooser.<init>()方法的具体详情如下:
包路径:javax.swing.JFileChooser
类名称:JFileChooser
方法名:<init>

JFileChooser.<init>介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

JFileChooser jFileChooser = new JFileChooser();
jFileChooser.setSelectedFile(new File("fileToSave.txt"));
jFileChooser.showSaveDialog(parent);

代码示例来源:origin: org.codehaus.groovy/groovy

public void actionPerformed(ActionEvent ae) {
    final JFileChooser jfc = new JFileChooser();
    final int response = jfc.showOpenDialog(LexerFrame.this);
    if (response != JFileChooser.APPROVE_OPTION) {
      return;
    }
    safeScanScript(jfc.getSelectedFile());
  }
};

代码示例来源: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: 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: stanfordnlp/CoreNLP

private static JFileChooser createFileChooser() {
 final JFileChooser chooser = new JFileChooser();
 //  sets up default file view
 try {
  chooserFile = new File((new File(".").getCanonicalPath()));
 } catch (Exception e) {
  // go with current directory.
 }
 chooser.setCurrentDirectory(chooserFile);
 chooser.addActionListener(e -> {
  if(e.getActionCommand().equals("ApproveSelection")) {
   chooserFile = chooser.getSelectedFile();
  }
 });
 chooser.setMultiSelectionEnabled(true);
 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
 return chooser;
}

代码示例来源:origin: cmusphinx/sphinx4

file = new File(filename);
    url = new File(args[1]).toURI().toURL();
  } else {
    url = AudioTool.class.getResource("spectrogram.config.xml");
  fileChooser = new JFileChooser();
  createMenuBar(jframe);

代码示例来源:origin: stackoverflow.com

import javax.swing.JFileChooser;
javax.swing.filechooser.FileSystemView;

public class GetMyDocuments {
 public static void main(String args[]) {
   JFileChooser fr = new JFileChooser();
   FileSystemView fw = fr.getFileSystemView();
   System.out.println(fw.getDefaultDirectory());
 }
}

代码示例来源: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: EngineHub/WorldEdit

public static File showSaveDialog(String[] exts) {
  JFileChooser dialog = new JFileChooser();
  if (exts != null) {
    dialog.setFileFilter(new ExtensionFilter(exts));
  }
  int returnVal = dialog.showSaveDialog(null);
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    return dialog.getSelectedFile();
  }
  return null;
}

代码示例来源:origin: stackoverflow.com

JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);
chooser.showOpenDialog(frame);
File[] files = chooser.getSelectedFiles();
if(files.length >= 2) {
  compare(readFileAsList(files[0]), readFileAsList(files[1]));
}

代码示例来源:origin: stackoverflow.com

JFileChooser saveFile = new JFileChooser();
saveFile.showSaveDialog(null);
JFileChooser openFile = new JFileChooser();
openFile.showOpenDialog(null);

代码示例来源: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

代码示例来源:origin: stackoverflow.com

JFileChooser j = new JFileChooser();
j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
Integer opt = j.showSaveDialog(this);

代码示例来源: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: 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: stackoverflow.com

JFileChooser chooser = new JFileChooser( new File(".") )
{
  public void approveSelection()
  {
    if (getSelectedFile().isFile())
    {
      // beep
      return;
    }
    else
      super.approveSelection();
  }
};

代码示例来源:origin: log4j/log4j

/**
 * Uses a JFileChooser to select a file to opened with the
 * LF5 GUI.
 */
protected void requestOpen() {
 JFileChooser chooser;
 if (_fileLocation == null) {
  chooser = new JFileChooser();
 } else {
  chooser = new JFileChooser(_fileLocation);
 }
 int returnVal = chooser.showOpenDialog(_logMonitorFrame);
 if (returnVal == JFileChooser.APPROVE_OPTION) {
  File f = chooser.getSelectedFile();
  if (loadLogFile(f)) {
   _fileLocation = chooser.getSelectedFile();
   _mruFileManager.set(f);
   updateMRUList();
  }
 }
}

代码示例来源:origin: INRIA/spoon

@Override
  public void actionPerformed(ActionEvent e) {
    JFileChooser chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    boolean cont = chooser.showSaveDialog(SpoonModelTree.this) == JFileChooser.APPROVE_OPTION;
    if (cont) {
      SerializationModelStreamer ser = new SerializationModelStreamer();
      try {
        ser.save(factory, new FileOutputStream(chooser
            .getSelectedFile()));
      } catch (IOException e1) {
        Launcher.LOGGER.error(e1.getMessage(), e1);
      }
    }
  }
});

代码示例来源:origin: stackoverflow.com

JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);
chooser.showOpenDialog(frame);
File[] files = chooser.getSelectedFiles();

代码示例来源: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

相关文章

JFileChooser类方法