Esempio n. 1
0
  void doExeCommand() {
    JViewport viewport = scrollPane.getViewport();
    String strContent = new String();
    PSlider slider;
    int i;
    File fp = new File(dataFile);

    RandomAccessFile access = null;
    Runtime program = Runtime.getRuntime();
    String cmdTrigger = "trigger";

    boolean delete = fp.delete();

    try {
      fp.createNewFile();
    } catch (IOException ie) {
      System.err.println("Couldn't create the new file " + ie);
      // System.exit(-1);;
    }

    try {
      access = new RandomAccessFile(fp, "rw");
    } catch (IOException ie) {
      System.err.println("Error in accessing the file " + ie);
      // System.exit(-1);;
    }

    for (i = 0; i < COMPONENTS; i++) {
      slider = (PSlider) vSlider.elementAt(i);
      /* Modified on March 20th to satisfy advisors' new request */
      if (slider.isString == true) strContent = strContent + slider.getRealStringValue() + " ";
      else strContent = strContent + slider.getValue() + " ";
    }

    // Get value of the radio button group
    if (firstBox.isSelected() == true) strContent = strContent + "1";
    else strContent = strContent + "0";

    try {
      access.writeBytes(strContent);
      access.close();
    } catch (IOException ie) {
      System.err.println("Error in writing to file " + ie);
      // System.exit(-1);;
    }
    // Trigger the OpenGL program to update with new values
    try {
      Process pid = program.exec(cmdTrigger);
    } catch (IOException ie) {
      System.err.println("Couldn't run " + ie);
      // System.exit(-1);;
    }
    doSourceFileUpdate();
  }