コード例 #1
0
ファイル: ThumbMaker.java プロジェクト: ctrueden/web-toys
  private void setComponentsEnabled(boolean enabled) {
    list.setEnabled(enabled);
    process.setEnabled(enabled);
    remove.setEnabled(enabled);
    xres.setEnabled(enabled);
    yres.setEnabled(enabled);
    aspect.setEnabled(enabled);

    boolean b = aspect.isSelected() && enabled;
    colorLabel.setEnabled(b);
    colorBox.setEnabled(b);
    redLabel.setEnabled(b);
    red.setEnabled(b);
    redValue.setEnabled(b);
    greenLabel.setEnabled(b);
    green.setEnabled(b);
    greenValue.setEnabled(b);
    blueLabel.setEnabled(b);
    blue.setEnabled(b);
    blueValue.setEnabled(b);

    format.setEnabled(enabled);
    algorithm.setEnabled(enabled);
    prepend.setEnabled(enabled);
    append.setEnabled(enabled);
    output.setEnabled(enabled);
  }
コード例 #2
0
 /** Enables the speed slider. */
 public void enableSpeedSlider() {
   speedSlider.setEnabled(true);
 }
コード例 #3
0
 /** Disables the speed slider. */
 public void disableSpeedSlider() {
   speedSlider.setEnabled(false);
 }
コード例 #4
0
ファイル: ThumbMaker.java プロジェクト: ctrueden/web-toys
  /** Called for button presses and checkbox toggles. */
  public void actionPerformed(ActionEvent e) {
    Object src = e.getSource();

    // the source of the event is the add files button
    // so we need to let the user add some files!
    if (src == addFiles) {
      // create an appropriate file chooser
      JFileChooser myTempFileChooser = new JFileChooser((new File("")).getAbsolutePath());
      myTempFileChooser.setMultiSelectionEnabled(true);
      myTempFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
      myTempFileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
      myTempFileChooser.setFileHidingEnabled(true);

      // open the file chooser and get the user's selctions
      int returnCode = myTempFileChooser.showOpenDialog(this);

      // use the return info to add files if the
      // user selected any in the file chooser
      if (returnCode == JFileChooser.APPROVE_OPTION) {
        // grab the files the user selected
        File[] selectedFiles = myTempFileChooser.getSelectedFiles();

        // pull the files into the list
        changeFilesInList.importFileData(list, selectedFiles);
      }
    }

    // the source of the event was the process button
    else if (src == process) {
      if (((DefaultListModel) list.getModel()).size() == 0) return;

      setComponentsEnabled(false);
      final ThumbMaker tm = this;
      Thread t =
          new Thread(
              new Runnable() {
                public void run() {
                  tm.process();
                  setComponentsEnabled(true);
                }
              });
      t.start();

      // because we can't do it on quit, we are going to save
      // all the preference values when the user processes a set
      // of images
      savePreferences();
    }

    // the source of the event was the remove button
    else if (src == remove) {
      DefaultListModel model = (DefaultListModel) list.getModel();
      while (true) {
        int ndx = list.getSelectedIndex();
        if (ndx < 0) break;
        model.removeElementAt(ndx);
      }
    }

    // the source of the event was the preserve aspect check box
    else if (src == aspect) {
      boolean b = aspect.isSelected();
      colorLabel.setEnabled(b);
      colorBox.setEnabled(b);
      redLabel.setEnabled(b);
      red.setEnabled(b);
      redValue.setEnabled(b);
      greenLabel.setEnabled(b);
      green.setEnabled(b);
      greenValue.setEnabled(b);
      blueLabel.setEnabled(b);
      blue.setEnabled(b);
      blueValue.setEnabled(b);
    }

    // the source of the event is the "..." button,
    // we need to let the user select a destination file
    else if (src == dotDotDot) {
      // create an appropriate file chooser
      JFileChooser myTempFileChooser =
          new JFileChooser(new File(output.getText()).getAbsolutePath());
      myTempFileChooser.setMultiSelectionEnabled(false);
      myTempFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      myTempFileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
      myTempFileChooser.setFileHidingEnabled(true);

      // open the file chooser and get the user's selctions
      int returnCode = myTempFileChooser.showOpenDialog(this);

      // use the return info to set the directory if the
      // user selected one in the file chooser
      if (returnCode == JFileChooser.APPROVE_OPTION) {
        // grab the file the user selected
        File selectedFile = myTempFileChooser.getSelectedFile();

        // stuff the file path into the text field
        output.setText(selectedFile.getAbsolutePath());
      }
    }
  }