public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("confirm")) {
      int thread = 10;
      boolean isContinue = true;
      String str_thread = threadT.getText();
      if (str_thread.equals("")) {
      } else if (!isNumeric(str_thread)) {
        isContinue = false;
        JOptionPane.showMessageDialog(null, "please input Numeric into thread textfield!!!");
      } else {
        thread = Integer.valueOf(str_thread);
      }

      if (isContinue) {
        if (jtf.getText().equals("") || jpf.getText().equals("")) {
          JOptionPane.showMessageDialog(null, "please choose file folder: target or tool!");
        } else {
          jb[0].setVisible(false);
          progressP.setVisible(true);
          progressLabel.setText("backuping files...");
          startTime = System.currentTimeMillis();
          isStarted = true;
          new Thread(new CompressRunnable(jtf.getText(), jpf.getText(), this, thread)).start();
        }
      }
    } else if (e.getActionCommand().equals("cancle")) {
      System.exit(0);
    } else if (e.getActionCommand().equals("pngpath")) {
      jtf.setText(chooseFile());
    } else if (e.getActionCommand().equals("toolpath")) {
      jpf.setText(chooseFile());
    } else if (e.getActionCommand().equals("log")) {
      if (isStarted) {
        String[] cmd = {"cmd", "/c", log};
        excute(cmd);
      }
    } else if (e.getActionCommand().equals("whitename")) {
      if (isStarted) {
        String[] cmd = {"cmd", "/c", whiteName};
        excute(cmd);
      }
    }
  }
Ejemplo n.º 2
0
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("confirm")) {
      int thread = 10;
      boolean isContinue = true;
      String str_thread = threadT.getText();
      if (str_thread.equals("")) {
      } else if (!isNumeric(str_thread)) {
        isContinue = false;
        JOptionPane.showMessageDialog(null, "please input Numeric into thread textfield!!!");
      } else {
        thread = Integer.valueOf(str_thread);
      }

      if (isContinue) {
        if (jtf.getText().equals("") || jpf.getText().equals("")) {
          JOptionPane.showMessageDialog(null, "please choose file folder: target or tool!");
        } else {
          jb[0].setVisible(false);
          progressP.setVisible(true);
          progressLabel.setText("backuping files...");
          startTime = System.currentTimeMillis();
          isStarted = true;
          new Thread(new CompressRunnable(jtf.getText(), jpf.getText(), this, thread)).start();
        }
      }
    } else if (e.getActionCommand().equals("cancle")) {
      System.exit(0);
    } else if (e.getActionCommand().equals("pngpath")) {
      jtf.setText(chooseFile());
    } else if (e.getActionCommand().equals("toolpath")) {
      jpf.setText(chooseFile());
    } else if (e.getActionCommand().equals("log")) {
      if (isStarted) {
        String[] cmd = {"cmd", "/c", log};
        excute(cmd);
      }
    } else if (e.getActionCommand().equals("whitename")) {
      if (isStarted) {
        String[] cmd = {"cmd", "/c", whiteName};
        excute(cmd);
      } else {
        if (jtf.getText().equals("")) {
          JOptionPane.showMessageDialog(null, "please choose file folder you want to deal with");
        } else {
          backupPath = jtf.getText() + "Backup";
          String whiteNameF = backupPath + "\\whiteName.txt";
          File f = new File(backupPath);
          if (!f.exists()) {
            f.mkdirs();
          }
          File wf = new File(whiteNameF);
          try {
            if (!wf.exists()) {
              wf.createNewFile();
            }
          } catch (Exception ex) {
            ex.printStackTrace();
          }
          String[] cmd = {"cmd", "/c", whiteNameF};
          excute(cmd);
        }
      }
    }
  }