-
Notifications
You must be signed in to change notification settings - Fork 0
/
VerFaturasCliente.java
90 lines (76 loc) · 2.63 KB
/
VerFaturasCliente.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
89
90
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.PrintStream;
import java.io.IOException;
import java.io.File;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.nio.file.StandardOpenOption;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.io.FileNotFoundException;
import java.util.stream.Collectors;
public class VerFaturasCliente extends JFrame {
private JLabel label;
private JLabel label2;
private JLabel label3;
private JButton exit;
private String aux;
private JTextArea ta; // Text area
private JScrollPane sbrText; // Scroll pane for text area
public VerFaturasCliente (Users d, Info u) {
setLayout(new FlowLayout());
label = new JLabel ("<html><b>*** Faturas ***</b></html>");
add(label);
aux = "";
if (d.existeUser(u.getNIF())) {
Empresa em = (Empresa) u;
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, List<Fatura>> entrada : em.porClienteValor().entrySet()) {
sb.append("Cliente: " + entrada.getKey() + "\n\n");
for(Fatura f : entrada.getValue()) {
sb.append(f.specialToString());
sb.append("\n");
}
}
aux = sb.toString();
}
ta = new JTextArea(aux, 75, 30);
ta.setEditable(false);
//sbrText = new JScrollPane(ta,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
sbrText = new JScrollPane(ta);
sbrText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
add(sbrText);
exit = new JButton("Exit");
add(exit);
event e = new event(d);
exit.addActionListener(e);
pack();
}
public class event implements ActionListener {
private Users d;
event(Users dados){
super();
this.d=dados;
}
public void actionPerformed (ActionEvent e) {
try{
d.save(d);
}
catch(IOException e1) {
e1.printStackTrace();
}
System.exit(0);
}
}
public static void visualizar_cliente(Users b, Info u) {
VerFaturasCliente gui = new VerFaturasCliente(b,u);
gui.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
gui.setSize(600,900);
gui.setVisible(true);
gui.setTitle("JavaFaturas");
}
}