Repository navigation
Expand file tree
/
Copy pathcheckbox.java
More file actions
100 lines (86 loc) · 2.66 KB
/
Copy pathcheckbox.java
File metadata and controls
100 lines (86 loc) · 2.66 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package teste;
import java.awt.EventQueue;
import java.awt.Image;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class checkbox extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField valorDocumento;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
checkbox frame = new checkbox();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public checkbox() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel documento = new JLabel("");
JCheckBox estrangeiro = new JCheckBox("Estrangeiro");
JCheckBox nacional = new JCheckBox("Nacional");
nacional.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (nacional.isSelected() == true) {
estrangeiro.setSelected(false);
documento.setText("CPF");
}
}
});
nacional.setBounds(30, 7, 97, 23);
contentPane.add(nacional);
estrangeiro.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (estrangeiro.isSelected() == true) {
nacional.setSelected(false);
documento.setText("Passaporte");
}
}
});
estrangeiro.setBounds(280, 7, 97, 23);
contentPane.add(estrangeiro);
documento.setBounds(179, 63, 46, 14);
contentPane.add(documento);
valorDocumento = new JTextField();
valorDocumento.setBounds(235, 60, 86, 20);
contentPane.add(valorDocumento);
valorDocumento.setColumns(10);
ImageIcon iconReduzido = new ImageIcon("C:\\Users\\maria.r.brandao\\Downloads\\image-removebg-preview.png");
Image imagemReduzida = iconReduzido.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH);
JButton enviar = new JButton("Enviar", imagemReduzida);
enviar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String label = documento.getText();
String valor = valorDocumento.getText();
JOptionPane.showMessageDialog(null, label + " : " + valor);
}
});
enviar.setBounds(136, 88, 89, 23);
contentPane.add(enviar);
}
}