-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPDVFrame.java
More file actions
185 lines (144 loc) · 4.93 KB
/
PDVFrame.java
File metadata and controls
185 lines (144 loc) · 4.93 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
package portifolio;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.Scanner;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;
public class PDVFrame extends JFrame {
private JTextField txtVT;
private JTextField txtDesc;
private JTextField txtVP;
private JTextField txtTroco;
private JTextField txtTotal;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
PDVFrame frame = new PDVFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public PDVFrame() {
getContentPane().setBackground(Color.DARK_GRAY);
getContentPane().setForeground(Color.YELLOW);
setBackground(Color.BLUE);
getContentPane().setLayout(null);
txtVT = new JTextField();
txtVT.setBounds(87, 27, 96, 20);
getContentPane().add(txtVT);
txtVT.setColumns(10);
JLabel lblValorTotal = new JLabel("Valor Total:");
lblValorTotal.setForeground(Color.YELLOW);
lblValorTotal.setBounds(10, 30, 67, 14);
getContentPane().add(lblValorTotal);
txtDesc = new JTextField();
txtDesc.setBounds(87, 58, 96, 20);
getContentPane().add(txtDesc);
txtDesc.setColumns(10);
JLabel lblDesconto = new JLabel("Desconto %:");
lblDesconto.setForeground(Color.YELLOW);
lblDesconto.setBounds(10, 61, 67, 14);
getContentPane().add(lblDesconto);
JLabel lblTotalComDesconto = new JLabel("Total com Desconto:");
lblTotalComDesconto.setForeground(Color.YELLOW);
lblTotalComDesconto.setBounds(10, 151, 130, 14);
getContentPane().add(lblTotalComDesconto);
txtVP = new JTextField();
txtVP.setBounds(87, 89, 96, 20);
getContentPane().add(txtVP);
txtVP.setColumns(10);
JLabel lblValorPago = new JLabel("Valor Pago:");
lblValorPago.setForeground(Color.YELLOW);
lblValorPago.setBounds(10, 95, 67, 14);
getContentPane().add(lblValorPago);
txtTroco = new JTextField();
txtTroco.setBounds(144, 176, 96, 20);
getContentPane().add(txtTroco);
txtTroco.setColumns(10);
JLabel lblTroco = new JLabel("Troco:");
lblTroco.setForeground(Color.YELLOW);
lblTroco.setBounds(10, 179, 63, 14);
getContentPane().add(lblTroco);
txtTotal = new JTextField();
txtTotal.setBounds(144, 145, 96, 20);
getContentPane().add(txtTotal);
txtTotal.setColumns(10);
JLabel lblStatus = new JLabel("");
lblStatus.setBounds(348, 30, 48, 14);
getContentPane().add(lblStatus);
JButton btnNewButton = new JButton("Calcular Troco");
btnNewButton.setBounds(232, 57, 146, 23);
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
calcular();
}
});
getContentPane().add(btnNewButton);
JButton btnLimpar = new JButton("Limpar");
btnLimpar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
limpar();
}
});
btnLimpar.setBounds(232, 116, 96, 23);
getContentPane().add(btnLimpar);
JButton btnNewButton_1 = new JButton("Calcular Desconto");
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
calcularm();
}
});
btnNewButton_1.setBounds(236, 26, 146, 23);
getContentPane().add(btnNewButton_1);
}
/* horario() */
private void horario(AbstractButton lblStatus) {
Date Data = new Date();
DateFormat formatador = DateFormat.getDateInstance(DateFormat.FULL);
lblStatus.setText(formatador.format(Data));
}// FIM horario()
/* calcular() */
private void calcular() {
double VT,Desc,VP,Total,Troco;
DecimalFormat numero = new DecimalFormat("0.00");
VT = Double.parseDouble(txtVT.getText().replace(",", "."));
Desc = Double.parseDouble(txtDesc.getText().replace(",", "."));
VP = Double.parseDouble(txtVP.getText().replace(",", "."));
Total = VT - (Desc / 100 * (VT));
txtTotal.setText("R$ " + Total);
Troco = VP - Total;
txtTroco.setText("R$" + Troco);
}
private void calcularm() {
double VT,Desc,VP,Total,Troco;
DecimalFormat numero = new DecimalFormat("0.00");
VT = Double.parseDouble(txtVT.getText().replace(",", "."));
Desc = Double.parseDouble(txtDesc.getText().replace(",", "."));
Total = VT - (Desc / 100 * (VT));
txtTotal.setText("R$ " + Total);
}
/* limpar() */
private void limpar() {
txtVT.setText(null);
txtDesc.setText(null);
txtVP.setText(null);
txtTotal.setText(null);
txtTroco.setText(null);
}// FIM limpar()
}