Exemplo n.º 1
0
  private void targetFileButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_targetFileButtonActionPerformed
    JFileChooser fc;
    String defFile = targetFileTextField.getText();
    if (defFile.length() > 0) {
      fc = new JFileChooser(FilePathParser.getDir(defFile));
    } else {
      fc = new JFileChooser(MusiteInit.defaultPath);
    }

    String ext = "txt";
    fc.setSelectedFile(new File(defFile));
    ArrayList<String> exts = new ArrayList<String>(1);
    exts.add(ext);
    fc.setFileFilter(new FileExtensionsFilter(exts, "Text file (.txt)"));
    // fc.setAcceptAllFileFilterUsed(true);
    fc.setDialogTitle("Save to...");
    int returnVal = fc.showSaveDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      File file = fc.getSelectedFile();
      MusiteInit.defaultPath = file.getParent();

      String filePath = MusiteInit.defaultPath + File.separator + file.getName();
      targetFileTextField.setText(filePath);
    }
  } // GEN-LAST:event_targetFileButtonActionPerformed
Exemplo n.º 2
0
  private void trainXmlFileButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_trainXmlFileButtonActionPerformed
    JFileChooser fc = new JFileChooser(MusiteInit.defaultPath);
    ArrayList<String> exts = new ArrayList<String>(1);
    String ext = "xml";
    exts.add(ext);
    fc.setFileFilter(new FileExtensionsFilter(exts, "XML file (.xml)"));
    // fc.setAcceptAllFileFilterUsed(true);
    fc.setDialogTitle("Select a XML file...");
    int returnVal = fc.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      File file = fc.getSelectedFile();
      MusiteInit.defaultPath = file.getParent();

      String filePath = MusiteInit.defaultPath + File.separator + file.getName();
      trainXmlFileTextField.setText(filePath);

      String fileName = FilePathParser.getName(filePath);
      targetFileTextField.setText(MusiteInit.defaultPath + File.separator + fileName + "-test.txt");
    }
  } // GEN-LAST:event_trainXmlFileButtonActionPerformed