-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCategoryEditView.java
More file actions
91 lines (75 loc) · 2.42 KB
/
Copy pathCategoryEditView.java
File metadata and controls
91 lines (75 loc) · 2.42 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
package view;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JTextField;
import daoLibrary.CategoryDAO;
import modelsLibrary.Category;
import javax.swing.JTextArea;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class CategoryEditView extends JFrame {
private static final long serialVersionUID = 1L;
private JTextField jtxtNome;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
CategoryEditView frame = new CategoryEditView();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public CategoryEditView() {
this(0,"","");
}
public CategoryEditView(int idCater, String nomeC, String descC) {
setType(Type.UTILITY);
setUndecorated(true);
getRootPane().setBorder(BorderFactory.createMatteBorder(3, 3, 3, 3, Color.DARK_GRAY));
setSize(new Dimension(1300, 700));
setResizable(false);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
jtxtNome = new JTextField();
jtxtNome.setText("");
jtxtNome.setBounds(252, 180, 211, 20);
getContentPane().add(jtxtNome);
jtxtNome.setColumns(10);
jtxtNome.setText(nomeC);
JTextArea jtxtAreaDesc = new JTextArea();
jtxtAreaDesc.setBounds(252, 254, 211, 77);
getContentPane().add(jtxtAreaDesc);
jtxtAreaDesc.setText(descC);
JButton btnUpdateCater = new JButton("Atualizar Categoria");
btnUpdateCater.setBounds(252, 369, 211, 23);
getContentPane().add(btnUpdateCater);
btnUpdateCater.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Category categoria = new Category();
CategoryDAO ddcategoria = new CategoryDAO();
categoria.setIdCategoria(idCater);
categoria.setNome(jtxtNome.getText());
categoria.setDescricao(jtxtAreaDesc.getText());
ddcategoria.updateCategoria(categoria);
}
});
JButton jbtnCancelar = new JButton("Cancelar");
jbtnCancelar.setBounds(10, 466, 89, 23);
getContentPane().add(jbtnCancelar);
jbtnCancelar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
CategoryListView tlcategoria = new CategoryListView();
tlcategoria.setVisible(true);
dispose();
}
});
}
}