IAbout.java :  » Net » hyperpool-0.4.0 » vicazh » hyperpool » Java Open Source

Java Open Source » Net » hyperpool 0.4.0 
hyperpool 0.4.0 » vicazh » hyperpool » IAbout.java
package vicazh.hyperpool;

import javax.swing.*;
import java.awt.event.*;
import java.beans.*;

/**
 * The graphic about dialog
 * @author Victor Zhigunov
 * @version 0.2.0
 */
public class IAbout implements ActionListener, PropertyChangeListener {
  private JDialog dialog;
  private JOptionPane optionPane;
  /**
   * @param dialog about dialog
   */
  public IAbout(JDialog dialog) {
    this.dialog = dialog;
    optionPane = (JOptionPane) dialog.getContentPane();
    optionPane.addPropertyChangeListener(this);
  }
  public void actionPerformed(ActionEvent e) {
    dialog.setLocationRelativeTo(dialog.getOwner());
    dialog.setVisible(true);
    Object value = optionPane.getValue();
    if (value == JOptionPane.UNINITIALIZED_VALUE)
      return;
    optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);
  }
  public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();
    if (dialog.isVisible()
      && (e.getSource() == optionPane)
      && (prop.equals(JOptionPane.VALUE_PROPERTY)
        || prop.equals(JOptionPane.INPUT_VALUE_PROPERTY)))
      dialog.setVisible(false);
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.