Ejemplo n.º 1
0
  /**
   * The Memory Monitor sets up a 5 second Timer which displays the amount of remaining memory
   * (compared to the total memory we have).
   */
  private void setupMemoryMonitor() {
    memoryTimer = new java.util.Timer("Memory monitor", true);

    memoryTimer.schedule(
        new TimerTask() {
          @Override
          public void run() {
            // We need to set this off in the Event Thread.
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    // Calculate the memory we have.
                    long value =
                        (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())
                            / (1024 * 1024);
                    long max = Runtime.getRuntime().maxMemory() / (1024 * 1024);
                    int percentage = (int) (((double) value) / max * 100);

                    // Set the progress bar.
                    progressBar.setMinimum(0);
                    progressBar.setMaximum(100);
                    progressBar.setValue(percentage);

                    progressBar.setString(
                        value + " MB out of " + max + " MB (" + percentage + "%)");
                  }
                });
          }
        },
        new Date(),
        5000); // Every five seconds.
  }
  public ControleurPaiement(
      JPanel p,
      CardLayout cl,
      Table[] t,
      Component[] lC,
      Component[] pC,
      Component[] sC,
      VuePaiement v) {
    this.modeleTable = new ModeleTable();
    setLogComponents(lC);
    setPayComponents(pC);
    setStatComponents(sC);
    this.tables = t;
    this.panneau = p;
    this.cartes = cl;
    this.tableCounter = 0;
    this.difTemps = 0;

    // On raffraichi toutes les minutes
    java.util.Timer timer = new java.util.Timer();
    timer.schedule(new Refresh(this.tables, v), 0, 30000);
  }