-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTelaProduto.java
88 lines (68 loc) · 1.98 KB
/
TelaProduto.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
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
package br.imd.visao;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import br.imd.controle.Banco;
import br.imd.modelo.Fornecedor;
import br.imd.modelo.Produto;
public class TelaProduto extends JInternalFrame implements ActionListener{
// rótulos
JLabel lcodigo = new JLabel("Código.:");
JLabel ldescricao = new JLabel("Descrição.:");
JLabel lunidade = new JLabel("Unidade.:");
// campos
JTextField tcodigo = new JTextField();
JTextField tdescricao = new JTextField();
JTextField tunidade = new JTextField();
// botões
JButton b1 = new JButton("Submeter");
JButton b2 = new JButton("Limpar");
//Banco
Banco bc;
public TelaProduto(String str, Banco bc) {
super(str,false,true);
this.bc = bc;
Container ct = this.getContentPane();
ct.setLayout(null);
// coordenadas
lcodigo.setBounds(10,10,100,30);
tcodigo.setBounds(73,10,100,25);
ldescricao.setBounds(10,40,150,30);
tdescricao.setBounds(73,40,200,25);
lunidade.setBounds(10,70,100,30);
tunidade.setBounds(73,70,50,25);
// idem
b1.setBounds(10 ,140,100,30);
b2.setBounds(120,140,100,30);
// adicionando componentes
ct.add(lcodigo);
ct.add(tcodigo);
ct.add(ldescricao);
ct.add(tdescricao);
ct.add(lunidade);
ct.add(tunidade);
ct.add(b1);
ct.add(b2);
// evento dos botões
b1.addActionListener(this);
b2.addActionListener(this);
// especificações do formulário
setSize(350,230);
setTitle(str);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == b1){
Produto produto = new Produto(tcodigo.getText(),
tdescricao.getText(), tunidade.getText());
bc.inserirProduto(produto);
}
tcodigo.setText("");
tdescricao.setText("");
tunidade.setText("");
}
}