Esempio n. 1
0
  public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(prop)) fc.setSelectedFile(new File(name));
    else if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(prop)
        && !fc.getSelectedFile().isDirectory()) name = fc.getSelectedFile().getName();
  }
Esempio n. 2
0
  public void propertyChange(PropertyChangeEvent e) {
    boolean update = false;
    String prop = e.getPropertyName();

    // If the directory changed, don't show an image.
    if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(prop)) {
      file = null;
      update = true;

      // If a file became selected, find out which one.
    } else if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(prop)) {
      file = (File) e.getNewValue();
      update = true;
    }

    // Update the preview accordingly.
    if (update) {
      thumbnail = null;
      if (isShowing()) {
        loadImage();
        repaint();
      }
    }
  }