-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPasswordFieldExample2.java
38 lines (37 loc) · 1.27 KB
/
PasswordFieldExample2.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import javax.swing.*;
import java.awt.event.*;
public class PasswordFieldExample2{
public static void main(String[] args){
JFrame f = new JFrame("Exemplo de Campo de Senha");
final JLabel label = new JLabel();
label.setBounds(20, 150, 200, 50);
final JPasswordField valor = new JPasswordField();
valor.setBounds(100, 75, 100, 30);
JLabel l1 = new JLabel("Nome do usuario: ");
l1.setBounds(20, 20, 80, 30);
JLabel l2 = new JLabel("Senha:");
l2.setBounds(20, 75, 80, 30);
JButton b = new JButton("Login");
b.setBounds(100, 120, 80, 30);
final JTextField texto = new JTextField();
texto.setBounds(100, 20, 100, 30);
f.add(valor);
f.add(l1);
f.add(label);
f.add(l2);
f.add(b);
f.add(texto);
f.setSize(300, 300);
f.setLayout(null);
f.setVisible(true);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String dados = "Nome de usuário " +
texto.getText();
dados += ", Senha: " + new
String(valor.getPassword());
label.setText(dados);
}
});
}
}