Repository navigation
Expand file tree
/
Copy pathRenderCelda.java
More file actions
119 lines (110 loc) · 3.81 KB
/
Copy pathRenderCelda.java
File metadata and controls
119 lines (110 loc) · 3.81 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Graphics;
import Connection.Consult;
import Models.Bodega;
import java.awt.Color;
import java.awt.Component;
import java.util.List;
import java.util.stream.Collectors;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
/**
*
* @author AlexJPZ
*/
public class RenderCelda extends DefaultTableCellRenderer {
private int colum;
private int valor;
private Consult consult;
private String codigo;
public RenderCelda(int colum, int valor) {
this.colum = colum;
this.valor = valor;
consult = new Consult();
}
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column) {
JLabel cell = (JLabel) super.getTableCellRendererComponent(table, value, isSelected,
hasFocus, row, column);
switch (colum) {
case 0:
if (column == 5 || column == 3) {
cell.setForeground(new Color(0, 153, 102));
} else {
cell.setForeground(Color.BLACK);
}
break;
case 1:
if (column == 4 || column == 6) {
cell.setForeground(new Color(0, 153, 102));
} else {
cell.setForeground(Color.BLACK);
}
break;
case 4:
if (column == colum || column == 3) {
cell.setForeground(new Color(0, 153, 102));
} else {
cell.setForeground(Color.BLACK);
}
break;
case 8:
if (column == 2) {
if (cell.getText().equals("Activa")) {
cell.setForeground(Color.RED);
} else {
cell.setForeground(new Color(0, 153, 102));
}
} else {
cell.setForeground(Color.BLACK);
}
break;
case 9:
if (column == 3) {
if (valor >= Integer.valueOf(cell.getText())) {
cell.setForeground(Color.RED);
} else {
cell.setForeground(new Color(0, 153, 102));
}
} else {
cell.setForeground(Color.BLACK);
}
break;
case 10:
if (column == 3 || column == 4) {
cell.setForeground(new Color(0, 153, 102));
} else {
if (column == 1) {
codigo = cell.getText();
}
if (column == 2) {
List<Bodega> bodega = consult.bodega().stream()
.filter(b -> b.getCodigo().equals(codigo))
.collect(Collectors.toList());
if (0 == bodega.size()) {
cell.setForeground(Color.RED);
} else {
if (0 == bodega.get(0).getExistencia()) {
cell.setForeground(Color.RED);
} else {
cell.setForeground(new Color(0, 153, 102));
}
}
} else {
cell.setForeground(Color.BLACK);
}
}
break;
}
return cell;
}
}