private ProgressMonitorInputStream getMonitorableStream(InputStream stream, String message) {

    final ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(this, message, stream);

    ProgressMonitor progress = pmis.getProgressMonitor();
    progress.setMillisToDecideToPopup(1);
    progress.setMillisToPopup(1);

    return pmis;
  }
示例#2
0
  /**
   * Read word list from file with name WORDLISTFILENAME, and pass a Set containing those words to
   * the computer player to intialize its lexicon.
   */
  private void initLexicon(InputStream stream) {

    ProgressMonitorInputStream pmis;
    ProgressMonitor progress = null;
    pmis = new ProgressMonitorInputStream(this, "reading words", stream);
    progress = pmis.getProgressMonitor();
    progress.setMillisToDecideToPopup(10);
    Scanner s = new Scanner(pmis);
    myLexicon.load(s);
    try {
      pmis.close();
    } catch (IOException e) {
      JOptionPane.showMessageDialog(
          null, "Error Closing Stream", "Error", JOptionPane.ERROR_MESSAGE);
    }
  }
  private ProgressMonitorInputStream getMonitorableStream(File file, String message) {
    try {
      FileInputStream stream = new FileInputStream(file);
      if (stream == null) {
        System.out.println("null on " + file.getCanonicalPath());
      }
      final ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(this, message, stream);

      ProgressMonitor progress = pmis.getProgressMonitor();
      progress.setMillisToDecideToPopup(1);
      progress.setMillisToPopup(1);

      return pmis;
    } catch (IOException e) {
      showError("could not open " + file.getName());
      e.printStackTrace();
      return null;
    }
  }