Huella Digital

Descargar como txt, pdf o txt
Descargar como txt, pdf o txt
Está en la página 1de 13

Clase Util.

java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package procedimientos;
import
import
import
import
import
import
import
import
import
import
import
import
import
import

com.griaule.grfingerjava.FingerprintImage;
com.griaule.grfingerjava.IFingerEventListener;
com.griaule.grfingerjava.IImageEventListener;
com.griaule.grfingerjava.IStatusEventListener;
com.griaule.grfingerjava.GrFingerJava;
com.griaule.grfingerjava.GrFingerJavaException;
java.io.File;
com.griaule.grfingerjava.MatchingContext;
com.griaule.grfingerjava.Template;
interfaz.PantallaPrincipal;
java.io.ByteArrayInputStream;
java.sql.*;
javax.swing.*;
java.sql.ResultSet;

public class Util implements IStatusEventListener, IImageEventListener, IFingerE


ventListener{
/**Conexin a la base de datos*/
private Connection dbConnection;
/**Consultas preparadas**/
private PreparedStatement guardarStmt;
private PreparedStatement guardarStmt2;
private PreparedStatement identificarStmt;
private PreparedStatement verificarStmt;
private PreparedStatement verificarCedula;
@Override
public void onSensorPlug(String idSensor) {
try {
GrFingerJava.startCapture(idSensor, this, this);
} catch (GrFingerJavaException e) {
e.printStackTrace();
}
// throw new UnsupportedOperationException(Not supported yet.);
}
@Override
public void onSensorUnplug(String idSensor) {
try {
GrFingerJava.stopCapture(idSensor);
} catch (GrFingerJavaException e) {
e.printStackTrace();
}
throw new UnsupportedOperationException(Not supported yet.);
}
@Override
public void onImageAcquired(String idSensor, FingerprintImage huellaDigital) {
//Almacena la imagen de la huella
this.fingerprint=huellaDigital;
this.fingerprint2=huellaDigital;

//Muestra la imagen obtenida


ui.showImage(huellaDigital);
//Muestra la plantilla en la imagen actual
extract();
throw new UnsupportedOperationException(Not supported yet.);
}
@Override
public void onFingerDown(String idSensor) {
throw new UnsupportedOperationException(Not supported yet.);
}
@Override
public void onFingerUp(String idSensor) {
throw new UnsupportedOperationException(Not supported yet.);
}
public static void setFingerprintSDKNativeDirectory(String directorio) {
File directory = new File(directorio);
try {
GrFingerJava.setNativeLibrariesDirectory(directory);
GrFingerJava.setLicenseDirectory(directory);
} catch (GrFingerJavaException e) {
e.printStackTrace();
}
}
/**Contexto utilizado para la captura, extraccin y coincidencia de huellas digita
les */
private MatchingContext fingerprintSDK;
/**Interfaz de usuario donde se muestra la imagen de la huella*/
private PantallaPrincipal ui;
/** Indica si la plantilla o template debe ser extrada automticamente*/
private boolean autoExtract = true;
/** Contiene localmente los datos de la huella capturada */
private ByteArrayInputStream fingerprintData, fingerprintData2;
/**Contiene la longitud del dato de la huella*/
private int fingerprintDataLength, fingerprintDataLength2;
/** La imagen de la ltima huella digital capturada. */
private FingerprintImage fingerprint, fingerprint2;
/** La plantilla de la ltima imagen de huella capturada */
public Template template;
public Util(PantallaPrincipal ui) {
this.ui = ui;
initDB();
}
/**
* Inicializa el Fingerprint SDK y habilita la captura de huellas.
*/
public void inicializarCaptura() {

try {
fingerprintSDK = new MatchingContext();
//Inicializa la captura de huella digital.
GrFingerJava.initializeCapture(this);
} catch (Exception e) {
//Si ocurre un error se cierra la aplicacin.
e.printStackTrace();
System.exit(1);
}
}
/**
* Este mtodo es llamado cada vez que la imagen de una huella ha sido capturada.
*/
/**
* Inicializa la conexin a la base de datos y prepara las operaciones para inserta
r,
* eliminar y modificar los datos
*/
private void initDB() {
try {
//Carga el driver ODBC
Class.forName(com.mysql.jdbc.Driver);
//Se conecta a la bd
dbConnection = DriverManager.getConnection(jdbc:mysql://172.17.17.152:3306/biomet
ria,biometria, b10m3tr14.);
Statement stm = dbConnection.createStatement();
//Prepara las consultas/sentencias que se utilizarn
//guardarStmt = dbConnection.prepareStatement(INSERT INTO huellas(id, nombres, hu
ella1) values(?,?,?));
guardarStmt = dbConnection.prepareStatement(INSERT INTO huella(cedula,nombres,hue
lla1,huella2) values(?,?,?,?));
guardarStmt2 = dbConnection.prepareStatement(INSERT INTO huella(huella2) values(?
));
identificarStmt = dbConnection.prepareStatement(SELECT nombres, huella1 FROM huel
la);
verificarStmt = dbConnection.prepareStatement(SELECT nombres FROM huella WHERE hu
ella1=?);
verificarCedula = dbConnection.prepareStatement(SELECT id FROM huellas WHERE id=?)
;
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Cierra la conexin a la base de datos y libera los recursos empleados.
*/
private void destroyDB() {
try {
//Se cierran todas las sentencias
guardarStmt.close();
identificarStmt.close();
//Cierra la conexin a la base

dbConnection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Extrae la plantilla de la imagen de la huella actual.
*/
public void extract() {
try {
//Extrae la plantilla de la imagen.
template = fingerprintSDK.extract(fingerprint);
//Muestra la plantilla en la imagen
ui.showImage(GrFingerJava.getBiometricImage(template,fingerprint));
} catch (GrFingerJavaException e) {
e.printStackTrace();
}
}
/*
* Guarda los datos de la huella digital actual en la base de datos
*/
public void guardarHuella(){
//Obtiene los datos del template de la huella actual
fingerprintData = new ByteArrayInputStream(template.getData());
fingerprintDataLength = template.getData().length;
fingerprintData2 = new ByteArrayInputStream(template.getData());
fingerprintDataLength2 = template.getData().length;
//Pregunta la identificacion y el nombre de la persona a la cual corresponde dic
ha huella
String cedula = JOptionPane.showInputDialog(Cedula:);
String nombre = JOptionPane.showInputDialog(Nombre:);
int ident = Integer.parseInt(cedula);
try {
//Establece los valores para la sentencia SQL
guardarStmt.setInt(1, ident);
guardarStmt.setString(2,nombre);
guardarStmt.setBinaryStream(3, fingerprintData, fingerprintDataLength);
guardarStmt.setBinaryStream(4, fingerprintData2, fingerprintDataLength);
//Ejecuta la sentencia
guardarStmt.execute();
JOptionPane.showMessageDialog(ui, Datos ingresados correctamente);
} catch (SQLException ex) {
//Si ocurre un error lo indica en la consola
System.err.println(Error al guardar los datos de la huella.);
ex.printStackTrace();
}
}
/**
* Verifica la huella digital actual contra otra en la base de datos
*/
public void verify(String nom) {
try {

//Obtiene la plantilla correspondiente a la persona indicada


verificarStmt.setString(1,nom);
ResultSet rs = verificarStmt.executeQuery();
//Si se encuentra el nombre en la base de datos
if (rs.next()){
//Lee la plantilla de la base de datos
byte templateBuffer[] = rs.getBytes(huella1);
//Crea una nueva plantilla
Template referenceTemplate = new Template(templateBuffer);
//compara las plantilas (actual vs bd)
boolean coinciden = fingerprintSDK.verify(template,referenceTemplate);
//Si corresponden, dibuja el mapa de correspondencia y lo indica con un mensaje
if (coinciden){
ui.showImage(GrFingerJava.getBiometricImage(template, fingerprint, fingerprintSD
K));
JOptionPane.showMessageDialog(ui, Las huellas s coinciden);
} else {
//De no ser as lo indica con un mensaje
JOptionPane.showMessageDialog(ui, No corresponde la huella con +nom, Error, JOptionP
ane.ERROR_MESSAGE);
}
//Si no encuentra alguna huella correspondiente
//al nombre lo indica con un mensaje
} else {
JOptionPane.showMessageDialog(ui, No existe el registro de +nom, Error, JOptionPane.
ERROR_MESSAGE);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (GrFingerJavaException e) {
e.printStackTrace();
}
}
/**
* Identifica a una persona registrada por medio de su huella digital
*/
public void identificarPersona(){
try{
ResultSet rsIdentificar = identificarStmt.executeQuery();
while(rsIdentificar.next()){
byte templateBuffer[] = rsIdentificar.getBytes(huella1);
Template referenceTemplate = new Template(templateBuffer);
boolean coinciden = fingerprintSDK.verify(template,referenceTemplate);
if (coinciden){
ui.showImage(GrFingerJava.getBiometricImage(template, fingerprint, fingerprintSD
K));
JOptionPane.showMessageDialog(ui, Bienvenido(a) +rsIdentificar.getString(nombres));
String url=http://login.unad.edu.co”;
try{
Runtime.getRuntime().exec(rundll32 url.dll,FileProtocolHandler + url);
}
catch(Exception err){
JOptionPane.showMessageDialog(null,Error: +err);
}

return;
}
}
JOptionPane.showMessageDialog(ui, Usuario no autorizado. Debe estar registrado pa
ra poder tener accoso a la aplicacion);
}
catch (SQLException e) {
e.printStackTrace();
} catch (GrFingerJavaException e) {
e.printStackTrace();
}
}
}
Clase PantallaPrincipal.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* PantallaPrincipal.java
*
* Created on 3/11/2011, 10:03:44 AM
*/
package interfaz;
import java.awt.image.BufferedImage;
import javax.swing.JPanel;
import procedimientos.Util;
import javax.swing.UIManager;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.JComponent;
import javax.swing.border.BevelBorder;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.*;
import java.io.File;
import javax.swing.GroupLayout.ParallelGroup;
/**
*
* @author NAPSTER2011
*/
public class PantallaPrincipal extends JApplet {
//objeto usado para realizar todas las operaciones relacionadas al Fingerprint-S
DK
private Util procedimientosSDK;
//Panel para mostrar la huella digital
private JPanel fingerprintViewPanel = null;
private JPanel fingerprintViewPanel2 = null;
//Imagen de la huella actual
private BufferedImage fingerprintImage = null;
private BufferedImage fingerprintImage2 = null;
/* Crea una nueva forma de PantallaPrincipal */
public PantallaPrincipal() {
inicializar();

//initComponents();
/*Inicializa la captura de huellas*/
procedimientosSDK.inicializarCaptura();
/*centra la ventana en la pantalla*/
//setLocationRelativeTo(null);
/*hace visible la ventana*/
setVisible(true);
}
@Override
public void init() {
String grFingerNativeDirectory = new File(.).getAbsolutePath();
Util.setFingerprintSDKNativeDirectory(grFingerNativeDirectory);
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
//setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setName(PantallaPrincipal); // NOI18N
/*addWindowListener(new java.awt.event.WindowAdapter() {
public void windowActivated(java.awt.event.WindowEvent evt) {
formWindowActivated(evt);
}
});*/
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Huella 1, jav
ax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP));
jPanel1.setName(panelContenedor); // NOI18N
jPanel1.setLayout(new java.awt.BorderLayout());
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Acciones, jav
ax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP));

jButton2.setText(Guardar);
jButton2.setName(btnGuardar); // NOI18N
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText(Identificar);
jButton3.setName(btnIdentificar); // NOI18N
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(37, 37, 37)

.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TR
AILING, false)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupL
ayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing
.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TR
AILING, false)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALU
E))
.addGap(38, 38, 38))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(jButton2)
//.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short
.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(jButton3))
.addGap(22, 22, 22))
));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(31, 31, 31)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.
GroupLayout.PREFERRED_SIZE)
.addGap(29, 29, 29)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGap(156, 156, 156)
.addComponent(jPanel2, 0, 247, Short.MAX_VALUE)
.addGap(172, 172, 172))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(32, 32, 32)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.Group
Layout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.Gr
oupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE)
)));
jPanel1.getAccessibleContext().setAccessibleName(null);
//pack();
}
/** This method is called from within the constructor to

* initialize the form.


* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
/*@SuppressWarnings(unchecked)
// <editor-fold defaultstate=collapsed desc=Generated Code>//GEN-BEGIN:initComponent
s
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
setName(PantallaPrincipal); // NOI18N
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Coloque aqui
su huella, javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBord
er.TOP));
jPanel1.setName(panelContenedor); // NOI18N
jPanel1.setLayout(new java.awt.BorderLayout());
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Opciones, jav
ax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP));
jButton2.setText(Guardar);
jButton2.setName(btnGuardar); // NOI18N
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText(Identificar);
jButton3.setName(btnIdentificar); // NOI18N
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.
GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(jButton2)

.addComponent(jButton3))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.
GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.Group
Layout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.Group
Layout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.
GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1.getAccessibleContext().setAccessibleName(null);
}// </editor-fold>//GEN-END:initComponents
*/
private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:ev
ent_formWindowActivated
// TODO add your handling code here:
this.jPanel1.add(crearPanelHuella());
}//GEN-LAST:event_formWindowActivated
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
T:event_jButton2ActionPerformed
// TODO add your handling code here:
procedimientosSDK.guardarHuella();
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
T:event_jButton3ActionPerformed
// TODO add your handling code here:
procedimientosSDK.identificarPersona();
}//GEN-LAST:event_jButton3ActionPerformed
/**
* Mtodo utilizado para mostrar la imagen de la huella
* en el panel correspondiente.
*/
public void showImage(BufferedImage image) {
//Utiliza el imageProducer para crear una imagen de la huella digital
fingerprintImage = image;
fingerprintImage2 = image;
//Se dibuja la nueva imagen

repaint();
}
/**
* @param args the command line arguments
*/
/*public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInsta
lledLookAndFeels()) {
if (Nimbus.equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(PantallaPrincipal.class.getName()).log(java.u
til.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(PantallaPrincipal.class.getName()).log(java.u
til.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(PantallaPrincipal.class.getName()).log(java.u
til.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(PantallaPrincipal.class.getName()).log(java.u
til.logging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new PantallaPrincipal().setVisible(true);
}
});
}*/
/**
* Se establece el estilo visual de la aplicacin y se realiza la inicializacin de l
a clase
* que contiene los procedimientos principales.
**/
public void inicializar() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
System.err.println(No se pudo aplicar el estilo visual);
}
//Crea una instancia de Util
this.procedimientosSDK = new Util(this);
}
/**
* Crea el panel que contendr la imagen de la huella digital
*/
private JComponent crearPanelHuella() {
//Crea un panel nuevo para mostrar la huella
fingerprintViewPanel = new JPanel(){

//Se sobreescribe el mtodo paintComponent


//para habilitar la muestra de la imagen de la huella
public void paintComponent(Graphics g) {
super.paintComponent(g);
//Si hay una imagen para ser mostrada
if (fingerprintImage!=null) {
//Calcula el tamao y posicin de la imagen para ser pintada
//el tamao es ajustado para que ocupe todo el tamao del panel
Insets insets = getInsets();
int transX = insets.left;
int transY = insets.top;
int width = getWidth() getInsets().right getInsets().left;
int height = getHeight() getInsets().bottom getInsets().top;
//Se dibuja la imagen
g.drawImage(fingerprintImage, transX, transY, width, height, null);
}
}
};
//Se agrega un borde alrededor del panel
fingerprintViewPanel.setBorder(new CompoundBorder (
new EmptyBorder (2,2,2,2),
new BevelBorder(BevelBorder.LOWERED)));
//si no hay existe el panel de la huella no devuelve nada
if(fingerprintViewPanel==null)
{
return null;
}else{ // de lo contrario devuelve el panel mismo
return fingerprintViewPanel;
}
}
private JComponent crearPanelHuella2() {
//Crea un panel nuevo para mostrar la huella
fingerprintViewPanel2 = new JPanel(){
//Se sobreescribe el mtodo paintComponent
//para habilitar la muestra de la imagen de la huella
public void paintComponent(Graphics g) {
super.paintComponent(g);
//Si hay una imagen para ser mostrada
if (fingerprintImage2!=null) {
//Calcula el tamao y posicin de la imagen para ser pintada
//el tamao es ajustado para que ocupe todo el tamao del panel
Insets insets = getInsets();
int transX = insets.left;
int transY = insets.top;
int width = getWidth() getInsets().right getInsets().left;
int height = getHeight() getInsets().bottom getInsets().top;
//Se dibuja la imagen
g.drawImage(fingerprintImage2, transX, transY, width, height, null);

}
}
};
//Se agrega un borde alrededor del panel
fingerprintViewPanel2.setBorder(new CompoundBorder (
new EmptyBorder (2,2,2,2),
new BevelBorder(BevelBorder.LOWERED)));
//si no hay existe el panel de la huella no devuelve nada
if(fingerprintViewPanel2==null)
{
return null;
}else{ // de lo contrario devuelve el panel mismo
return fingerprintViewPanel2;
}
}
// Variables declaration do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
// End of variables declaration//GEN-END:variables
}
Clase LectorHuella.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package lectorhuella;
import interfaz.PantallaPrincipal;
import java.io.File;
import procedimientos.Util;
import java.util.*;
/**
*
* @author NAPSTER2011
*/
public class LectorHuella {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String grFingerNativeDirectory = new File(.).getAbsolutePath();
Util.setFingerprintSDKNativeDirectory(grFingerNativeDirectory);
PantallaPrincipal p = new PantallaPrincipal();
}
}

También podría gustarte

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy