protected boolean setDir(JTextField txf, String strValue) {
    String strTxt = txf.getText();
    String strName = txf.getName();
    boolean bSet = false;

    if ((strTxt == null || strTxt.trim().length() == 0 || strTxt.equals(INFOSTR))
        && strName.equalsIgnoreCase("value")) {
      if (timer != null) {
        timer.cancel();
        txf.setForeground(Color.black);
      }

      bSet = true;
      txf.setText(strValue);
      txf.grabFocus();
    }
    return bSet;
  }
Beispiel #2
0
  protected void doBlink() {
    if (timer != null) timer.cancel();

    timer = new java.util.Timer();
    timer.schedule(
        new TimerTask() {
          public void run() {
            WUtil.blink(validateButton);
          }
        },
        delay,
        delay);
  }
Beispiel #3
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.
  }
Beispiel #4
0
 public void actionPerformed(ActionEvent e) {
   String cmd = e.getActionCommand();
   if (cmd.equals("close")) {
     if (m_nType == CONFIG) saveData();
     else if (m_nType == DEFAULT && m_pnlAccPolicy != null) m_pnlAccPolicy.saveData();
     setVisible(false);
     dispose();
   } else if (cmd.equals("validate")) {
     if (timer != null) timer.cancel();
     if (m_nType == CHECKSUM && m_pnlChecksum != null) m_pnlChecksum.checksumValidation();
     else doSysValidation();
     validateButton.setBackground(closeButton.getBackground());
   } else if (cmd.equals("checksum")) {
     String strValue = m_pnlChecksum.getChecksum();
     m_pnlChecksum.setData(strValue);
   } else if (cmd.equals("checksumdir")) {
     m_pnlChecksum.setData("");
   } else if (cmd.equals("cancel")) {
     // build(m_bAccPolicy);
     setVisible(false);
     dispose();
   } else if (cmd.equals("help")) displayHelp();
 }