/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.fp.firma.component;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;

/**
 * Dialog que permite el ingreso del password del token para la firma
 * @author dcruz
 */
public class PasswordDialog extends JDialog implements ActionListener, PropertyChangeListener{

    private JPasswordField txtPasswordCertificado;
    
    public PasswordDialog(){
        super();
        txtPasswordCertificado = new JPasswordField();
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        addComponentListener(new ComponentAdapter() {
            @Override
            public void componentShown(ComponentEvent ce) {
                txtPasswordCertificado.requestFocusInWindow();
            }
        });
        txtPasswordCertificado.addActionListener(this);
    }
    
    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    public void propertyChange(PropertyChangeEvent evt) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
    /** This method clears the dialog and hides it. */
    public void clearAndHide() {
        txtPasswordCertificado.setText(null);
        setVisible(false);
    }
}
