Aplicação simples de password
Publicado por Alberto Ivo 10/08/2006
[ Hits: 7.883 ]
Veja como fazer um simples password em Java num frame.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class PasswordField extends JFrame {
private JLabel label;
private JPasswordField passwordField;
public PasswordField()
{
super( "Testing JTextField and JPasswordField" );
Container container = getContentPane();
container.setLayout( new FlowLayout() );
label = new JLabel("Digite algo e pressione Enter. \n");
container.add( label );
passwordField = new JPasswordField( "Viva o Linux" );
container.add( passwordField );
TextFieldHandler handler = new TextFieldHandler();
passwordField.addActionListener( handler );
setSize( 325, 100 );
setVisible( true );
}
public static void main( String args[] )
{
PasswordField application = new PasswordField();
application.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE );
}
private class TextFieldHandler implements ActionListener {
public void actionPerformed( ActionEvent event )
{
String string = "";
if ( event.getSource() == passwordField ) {
JPasswordField pwd = ( JPasswordField ) event.getSource();
string = "passwordField: " +
new String( passwordField.getPassword() );
}
JOptionPane.showMessageDialog( null, string );
}
}
}
Nenhum comentário foi encontrado.
Monitorando o Preço do Bitcoin ou sua Cripto Favorita em Tempo Real com um Widget Flutuante
IA Turbina o Desktop Linux enquanto distros renovam forças
Como extrair chaves TOTP 2FA a partir de QRCODE (Google Authenticator)
Como realizar um ataque de força bruta para desobrir senhas?
Como usar Gpaste no ambiente Cinnamon
Atualizando o Fedora 42 para 43
Scripts ou binários [RESOLVIDO] (3)
VOL já não é mais como antes? (10)
Pergunta: Meu teclado não está respondendo direito como e consertar? ... (4)









