Created
February 13, 2020 00:29
-
-
Save HashRaygoza/a72a75bed001bc7f61ee383d84c183aa to your computer and use it in GitHub Desktop.
Manejador de eventos de documento
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.hash.databaseio.doclistener; | |
| import javax.swing.JOptionPane; | |
| import javax.swing.JPasswordField; | |
| import javax.swing.SwingUtilities; | |
| import javax.swing.event.DocumentEvent; | |
| import javax.swing.event.DocumentListener; | |
| /** | |
| * | |
| * @author draygoza | |
| */ | |
| public class CuentaCaracteres implements DocumentListener, Runnable { | |
| private final JPasswordField campoPassword; | |
| static private final int DATA_LENGTH = 80; | |
| public CuentaCaracteres(JPasswordField c) { | |
| campoPassword = c; | |
| } | |
| @Override | |
| public void insertUpdate(DocumentEvent e) { | |
| String texto = new String(campoPassword.getPassword()); | |
| if(texto.length() == CuentaCaracteres.DATA_LENGTH) { | |
| SwingUtilities.invokeLater(this); | |
| } | |
| } | |
| @Override | |
| public void removeUpdate(DocumentEvent e) { | |
| } | |
| @Override | |
| public void changedUpdate(DocumentEvent e) { | |
| } | |
| @Override | |
| public void run() { | |
| campoPassword.requestFocus(); | |
| JOptionPane.showMessageDialog(campoPassword, "TODOS LOS DATOS LEIDOS"); | |
| campoPassword.setText(""); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment