5 import java.awt.SystemColor;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
8 import java.awt.event.MouseAdapter;
9 import java.awt.event.MouseEvent;
10 import java.util.regex.Matcher;
11 import java.util.regex.Pattern;
13 import javax.swing.ButtonGroup;
14 import javax.swing.ImageIcon;
15 import javax.swing.JButton;
16 import javax.swing.JFrame;
17 import javax.swing.JLabel;
18 import javax.swing.JOptionPane;
19 import javax.swing.JPanel;
20 import javax.swing.JRadioButton;
21 import javax.swing.JSeparator;
22 import javax.swing.JTextField;
24 import domain.RegularUser;
26 public class RecargarSaldoGUI extends JFrame {
28 private RegularUser userlog;
29 private RegularUser userActualizado;
30 private final ButtonGroup buttonGroup = new ButtonGroup();
31 private JTextField textNumTar;
32 private JTextField textCadTar1;
33 private JTextField textCadTar2;
35 private JTextField textVerifTar;
36 private JTextField textCuentaB;
37 private JLabel labelNumTar = new JLabel("Número de tarjeta:");
38 private JLabel labelCadTar = new JLabel("Caducidad:");
39 // private JLabel labelVerifTar = new JLabel(
40 // ResourceBundle.getBundle("Etiquetas").getString("RecargarSaldoGUI.labelVerifTar.text")); //$NON-NLS-1$ //$NON-NLS-2$
41 private JLabel labelVerifTar = new JLabel("Código de seguridad:"); //$NON-NLS-1$ //$NON-NLS-2$
42 private JLabel labelCuentaB = new JLabel("Número de cuenta:");
43 private JRadioButton radioCuentaB = new JRadioButton("Cuenta bancaria");
44 private JRadioButton radioTarjeta = new JRadioButton("Tarjeta de crédito");
45 private JPanel panel = new JPanel();
46 private JLabel lblPagarCon = new JLabel("");
47 private JLabel lblIconoTarjetas = new JLabel();
48 private final JLabel lblInfoCad = new JLabel();
49 private final JLabel lblIcono2;
50 private final JLabel lblIcono3;
51 private final JLabel lblInfoCodSeg = new JLabel();
52 private final JLabel lblImporte = new JLabel();
53 private JTextField textImporte;
54 private final JPanel panel_1 = new JPanel();
55 private final JLabel lblSaldoActualizado = new JLabel();
56 private final JLabel lblSaldoActual = new JLabel();
57 private final JPanel panel_2 = new JPanel();
58 private final JLabel lblSaldoActualInfo = new JLabel(); // $NON-NLS-1$ //$NON-NLS-2$
59 private final JLabel lblSaldoPrevisto = new JLabel(); // $NON-NLS-1$ //$NON-NLS-2$
60 private final JLabel lblUsername = new JLabel();
61 private final JLabel lblNombre = new JLabel(); // $NON-NLS-1$ //$NON-NLS-2$
62 // private final JLabel lblNewLabel = new JLabel(
63 // ResourceBundle.getBundle("Etiquetas").getString("RecargarSaldoGUI.lblNewLabel.text")); //$NON-NLS-1$ //$NON-NLS-2$
64 private final JLabel lblNewLabel = new JLabel("Nombre de usuario:"); //$NON-NLS-1$ //$NON-NLS-2$
65 // private final JLabel lblNewLabel_1 = new JLabel(
66 // ResourceBundle.getBundle("Etiquetas").getString("RecargarSaldoGUI.lblNewLabel_1.text")); //$NON-NLS-1$ //$NON-NLS-2$
67 private final JLabel lblNewLabel_1 = new JLabel("Nombre y Apellido"); //$NON-NLS-1$ //$NON-NLS-2$
68 private JLabel lblActualizarSaldo;
69 // private JButton btnCargarSaldo = new JButton(
70 // ResourceBundle.getBundle("Etiquetas").getString("MainGUI.cargarSaldo"));
71 private JButton btnCargarSaldo = new JButton("cargarSaldo");
72 private JButton btnCancelar = new JButton("Cancelar");
74 private businessLogic.BLFacade facade = LoginGUI.getBusinessLogic();
75 // private final JLabel lblNewLabel_2 = new JLabel(
76 // ResourceBundle.getBundle("Etiquetas").getString("RecargarSaldoGUI.lblNewLabel_2.text")); //$NON-NLS-1$ //$NON-NLS-2$
77 private final JLabel lblNewLabel_2 = new JLabel("Recarga mínima de 1€"); //$NON-NLS-1$ //$NON-NLS-2$
78 private final JLabel lblErrorPrevio = new JLabel("Error: importe vacío");
79 private JTextField texto;
81 private Object objeto = new Object();
82 private JLabel lblIconoTarjetas_1;
84 public RecargarSaldoGUI(RegularUser ru) {
85 getContentPane().setBackground(Color.WHITE);
88 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
89 setTitle("Recargar saldo"
91 + userlog.getUserName());
93 this.setSize(1400, 800);
95 getContentPane().setLayout(null);
97 JLabel lblInfo = new JLabel("Aquí podrás recargar tu saldo. Puedes elegir los siguientes métodos de pago:");
98 lblInfo.setBounds(85, 51, 494, 13);
99 getContentPane().add(lblInfo);
101 JLabel lblTarjetaDeCrdito = new JLabel("⚫ Tarjeta de crédito\r\n");
102 lblTarjetaDeCrdito.setToolTipText("");
103 lblTarjetaDeCrdito.setBounds(85, 76, 494, 13);
104 getContentPane().add(lblTarjetaDeCrdito);
106 JLabel lblCuentaBancaria = new JLabel("⚫ Cuenta bancaria");
107 lblCuentaBancaria.setToolTipText("");
108 lblCuentaBancaria.setBounds(85, 98, 494, 13);
109 getContentPane().add(lblCuentaBancaria);
111 ImageIcon icon = new ImageIcon("imagenes/info.png");
113 JSeparator separator = new JSeparator();
114 separator.setBounds(85, 155, 457, 13);
115 getContentPane().add(separator);
116 radioTarjeta.setBackground(Color.WHITE);
118 radioTarjeta.addActionListener(new ActionListener() {
120 public void actionPerformed(ActionEvent arg0) {
122 radioCuentaB.setForeground(Color.black);
123 lblIconoTarjetas.setVisible(true);
124 lblIconoTarjetas_1.setVisible(true);
125 lblInfoCad.setVisible(true);
126 lblIcono2.setVisible(true);
127 lblIcono3.setVisible(true);
128 lblInfoCodSeg.setVisible(true);
129 textImporte.setVisible(true);
130 lblImporte.setVisible(true);
131 lblActualizarSaldo.setVisible(true);
132 btnCargarSaldo.setVisible(true);
133 btnCancelar.setVisible(true);
135 lblPagarCon.setText("PAGAR CON TARJETA");
136 radioTarjeta.setFont(new Font("Dialog", Font.BOLD, 14));
137 radioTarjeta.setForeground(SystemColor.textHighlight);
138 textCuentaB.setVisible(false);
139 labelCuentaB.setVisible(false);
140 textNumTar.setVisible(true);
141 textCadTar1.setVisible(true);
142 textCadTar2.setVisible(true);
143 textVerifTar.setVisible(true);
144 labelNumTar.setVisible(true);
145 labelCadTar.setVisible(true);
146 labelVerifTar.setVisible(true);
150 radioTarjeta.setFont(new Font("Dialog", Font.BOLD, 14));
151 buttonGroup.add(radioTarjeta);
152 radioTarjeta.setBounds(942, 133, 243, 21);
153 getContentPane().add(radioTarjeta);
154 radioCuentaB.setBackground(Color.WHITE);
156 radioCuentaB.addActionListener(new ActionListener() {
158 public void actionPerformed(ActionEvent e) {
160 lblIconoTarjetas_1.setVisible(false);
161 lblPagarCon.setText("PAGAR CON CUENTA BANCARIA");
162 lblIconoTarjetas.setVisible(false);
163 lblInfoCad.setVisible(false);
164 lblIcono2.setVisible(false);
165 lblIcono3.setVisible(false);
166 lblInfoCodSeg.setVisible(false);
167 textImporte.setVisible(true);
168 lblImporte.setVisible(true);
169 lblActualizarSaldo.setVisible(true);
170 btnCargarSaldo.setVisible(true);
171 btnCancelar.setVisible(true);
173 radioTarjeta.setForeground(Color.black);
174 radioCuentaB.setForeground(SystemColor.textHighlight);
175 textCuentaB.setVisible(true);
176 labelCuentaB.setVisible(true);
177 textNumTar.setVisible(false);
178 textCadTar1.setVisible(false);
179 textCadTar2.setVisible(false);
180 textVerifTar.setVisible(false);
181 labelNumTar.setVisible(false);
182 labelCadTar.setVisible(false);
183 labelVerifTar.setVisible(false);
186 radioCuentaB.setFont(new Font("Dialog", Font.BOLD, 14));
187 buttonGroup.add(radioCuentaB);
188 radioCuentaB.setBounds(942, 98, 166, 21);
189 getContentPane().add(radioCuentaB);
191 panel.setBackground(Color.WHITE);
192 panel.setBorder(null);
193 panel.setForeground(Color.WHITE);
194 panel.setBounds(787, 180, 522, 532);
195 getContentPane().add(panel);
196 panel.setLayout(null);
198 ImageIcon icon5 = new ImageIcon("imagenes/tarjetas_credito2.png");
200 textVerifTar = new JTextField();
201 textVerifTar.setBounds(174, 281, 72, 39);
202 panel.add(textVerifTar);
203 textVerifTar.setVisible(false);
205 textVerifTar.setForeground(Color.GRAY);
206 textVerifTar.setFont(new Font("Arial", Font.PLAIN, 16));
207 textVerifTar.setColumns(10);
208 labelVerifTar.setBounds(30, 293, 160, 16);
209 panel.add(labelVerifTar);
210 labelCadTar.setBounds(30, 229, 160, 16);
211 panel.add(labelCadTar);
213 textCadTar1 = new JTextField();
214 textCadTar1.setBounds(174, 217, 72, 39);
215 panel.add(textCadTar1);
216 textCadTar1.setVisible(false);
218 textCadTar1.setForeground(Color.GRAY);
219 textCadTar1.setFont(new Font("Arial", Font.PLAIN, 16));
220 textCadTar1.setColumns(10);
222 textCadTar2 = new JTextField();
223 textCadTar2.setBounds(258, 217, 72, 39);
224 panel.add(textCadTar2);
225 textCadTar2.setVisible(false);
227 textCadTar2.setForeground(Color.GRAY);
228 textCadTar2.setFont(new Font("Arial", Font.PLAIN, 16));
229 textCadTar2.setColumns(10);
231 textNumTar = new JTextField();
232 textNumTar.setBounds(174, 152, 300, 39);
233 panel.add(textNumTar);
234 textNumTar.setVisible(false);
236 textNumTar.setForeground(Color.GRAY);
237 textNumTar.setFont(new Font("Arial", Font.PLAIN, 16));
238 textNumTar.setColumns(10);
240 textCuentaB = new JTextField();
241 textCuentaB.setBounds(174, 91, 300, 39);
242 panel.add(textCuentaB);
243 textCuentaB.setVisible(false);
244 textCuentaB.setForeground(Color.GRAY);
245 textCuentaB.setFont(new Font("Arial", Font.PLAIN, 16));
246 textCuentaB.setColumns(10);
247 labelCuentaB.setBounds(27, 103, 160, 16);
248 panel.add(labelCuentaB);
249 labelNumTar.setBounds(30, 164, 160, 16);
250 panel.add(labelNumTar);
251 lblPagarCon.setForeground(SystemColor.textHighlight);
252 lblPagarCon.setFont(new Font("Dialog", Font.BOLD, 18));
254 lblPagarCon.setBounds(24, 24, 349, 27);
255 panel.add(lblPagarCon);
256 lblInfoCad.setBounds(376, 230, 87, 16);
257 panel.add(lblInfoCad);
258 // lblInfoCad.setText(ResourceBundle.getBundle("Etiquetas").getString("RecargarSaldoGUI.lblInfoCad.text")); //$NON-NLS-1$ //$NON-NLS-2$
259 lblInfoCad.setText("MM (M) AA"); //$NON-NLS-1$ //$NON-NLS-2$
260 lblInfoCad.setVisible(false);
261 lblInfoCad.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 11));
262 lblInfoCad.setForeground(Color.GRAY);
264 ImageIcon icon2 = new ImageIcon("imagenes/info.png");
265 lblIcono2 = new JLabel(icon2);
266 lblIcono2.setBounds(348, 215, 27, 44);
267 lblIcono2.setVisible(false);
268 panel.add(lblIcono2);
270 ImageIcon icon3 = new ImageIcon("imagenes/info.png");
271 lblIcono3 = new JLabel(icon3);
272 lblIcono3.setBounds(268, 290, 30, 30);
273 panel.add(lblIcono3);
274 lblIcono3.setVisible(false);
276 // lblInfoCodSeg.setText(ResourceBundle.getBundle("Etiquetas").getString("RecargarSaldoGUI.lblInfoCodSeg.text")); //$NON-NLS-1$ //$NON-NLS-2$
277 lblInfoCodSeg.setText("XXX"); //$NON-NLS-1$ //$NON-NLS-2$
279 lblInfoCodSeg.setBounds(298, 293, 55, 16);
280 lblInfoCodSeg.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 11));
281 lblInfoCodSeg.setForeground(Color.GRAY);
282 lblInfoCodSeg.setVisible(false);
283 panel.add(lblInfoCodSeg);
284 lblImporte.setForeground(SystemColor.textHighlight);
285 lblImporte.setFont(new Font("Dialog", Font.BOLD, 20));
286 lblImporte.setBounds(30, 382, 120, 34);
287 lblImporte.setVisible(false);
288 lblImporte.setText("Importe:");
289 panel.add(lblImporte);
291 textImporte = new JTextField();
292 // textImporte.addKeyListener(new KeyAdapter() {
294 // public void keyTyped(KeyEvent arg0) {
299 // Float suma = Float.parseFloat(textImporte.getText() + Character.toString(arg0.getKeyChar()));
300 // lblSaldoActualizado.setText(suma.toString());
301 // System.out.println("FLOAT");
302 // } catch (Exception e) {
303 // System.out.println("NO ES FLOAT");
310 textImporte.setBounds(129, 382, 104, 40);
311 panel.add(textImporte);
312 textImporte.setVisible(false);
313 textImporte.setForeground(Color.GRAY);
314 textImporte.setFont(new Font("Arial", Font.PLAIN, 16));
315 textImporte.setColumns(10);
316 btnCargarSaldo.addActionListener(new ActionListener() {
319 public void actionPerformed(ActionEvent arg0) {
321 if (radioCuentaB.isSelected()) {
322 if (validoCuentaB(textCuentaB.getText()) == false) {
323 JOptionPane.showMessageDialog(getContentPane(), "Cuenta bancaria incorrecta", "Error",
324 JOptionPane.ERROR_MESSAGE);
328 Float montante = Float.parseFloat(textImporte.getText());
330 if (montante >= 1f) {
331 if (facade.recargarSaldo(userlog.getUserName(), montante)) {
332 JOptionPane.showMessageDialog(getContentPane(),
333 "Saldo recargado con éxito: " + montante + " €");
335 userActualizado = facade.getRegularUserByUsername(userlog.getUserName());
336 lblSaldoActual.setText(userActualizado.getBalance().toString() + " €");
341 JOptionPane.showMessageDialog(getContentPane(),
342 "El importe debe ser de un mínimo de 1 €", "Error", JOptionPane.ERROR_MESSAGE);
345 } catch (Exception e) {
346 JOptionPane.showMessageDialog(getContentPane(), "El importe es incorrecto", "Error",
347 JOptionPane.ERROR_MESSAGE);
351 } else if (radioTarjeta.isSelected()) {
353 if (validoTarjeta(textNumTar.getText()) == false) {
354 JOptionPane.showMessageDialog(getContentPane(), "Tarjeta de crédito incorrecta", "Error",
355 JOptionPane.ERROR_MESSAGE);
356 } else if (validoMes(textCadTar1.getText()) == false) {
357 JOptionPane.showMessageDialog(getContentPane(), "El mes debe ser entre 01 y 12", "Error",
358 JOptionPane.ERROR_MESSAGE);
359 } else if (validoAño(textCadTar2.getText()) == false) {
360 JOptionPane.showMessageDialog(getContentPane(), "El año debe ser entre 21 y 28", "Error",
361 JOptionPane.ERROR_MESSAGE);
362 } else if (validoCVC(textVerifTar.getText()) == false) {
363 JOptionPane.showMessageDialog(getContentPane(), "El CVC debe ser un número de 3 cifras",
364 "Error", JOptionPane.ERROR_MESSAGE);
368 Float montante = Float.parseFloat(textImporte.getText());
370 if (montante >= 1f) {
371 if (facade.recargarSaldo(userlog.getUserName(), montante)) {
373 JOptionPane.showMessageDialog(getContentPane(),
374 "Saldo recargado con éxito: " + montante + " €");
376 userActualizado = facade.getRegularUserByUsername(userlog.getUserName());
377 lblSaldoActual.setText(userActualizado.getBalance().toString() + " €");
380 JOptionPane.showMessageDialog(getContentPane(),
381 "El importe debe ser de un mínimo de 1 €", "Error", JOptionPane.ERROR_MESSAGE);
384 } catch (Exception e) {
385 JOptionPane.showMessageDialog(getContentPane(), "El importe es incorrecto", "Error",
386 JOptionPane.ERROR_MESSAGE);
395 btnCargarSaldo.setFont(new Font("Dialog", Font.BOLD, 14));
396 btnCargarSaldo.setBounds(334, 471, 140, 27);
397 panel.add(btnCargarSaldo);
398 btnCargarSaldo.setVisible(false);
399 btnCargarSaldo.setForeground(Color.WHITE);
400 btnCargarSaldo.setBackground(SystemColor.textHighlight);
401 btnCancelar.addActionListener(new ActionListener() {
403 public void actionPerformed(ActionEvent arg0) {
405 if (radioCuentaB.isSelected()) {
406 textCuentaB.setText("");
407 textImporte.setText("");
408 lblErrorPrevio.setVisible(false);
409 } else if (radioTarjeta.isSelected()) {
410 textNumTar.setText("");
411 textCadTar1.setText("");
412 textCadTar2.setText("");
413 textVerifTar.setText("");
414 textImporte.setText("");
415 lblErrorPrevio.setVisible(false);
422 btnCancelar.setForeground(Color.WHITE);
423 btnCancelar.setBackground(SystemColor.controlShadow);
424 btnCancelar.setVisible(false);
425 btnCancelar.setFont(new Font("Dialog", Font.BOLD, 14));
426 btnCancelar.setBounds(30, 472, 99, 26);
427 panel.add(btnCancelar);
429 lblActualizarSaldo = new JLabel("<HTML><U>Previo del futuro saldo</U></HTML>");
430 lblActualizarSaldo.setFont(new Font("Dialog", Font.BOLD, 10));
431 lblActualizarSaldo.setBounds(241, 394, 160, 16);
432 lblActualizarSaldo.setVisible(false);
434 panel.add(lblActualizarSaldo);
435 lblErrorPrevio.setForeground(Color.RED);
436 lblErrorPrevio.setFont(new Font("Dialog", Font.BOLD, 10));
437 lblErrorPrevio.setBounds(376, 394, 120, 16);
438 lblErrorPrevio.setVisible(false);
440 panel.add(lblErrorPrevio);
441 lblIconoTarjetas_1 = new JLabel(icon5);
442 lblIconoTarjetas_1.setVisible(false);
443 lblIconoTarjetas_1.setBounds(216, 74, 149, 30);
444 panel.add(lblIconoTarjetas_1);
445 lblActualizarSaldo.addMouseListener(new MouseAdapter() {
447 public void mouseClicked(MouseEvent arg0) {
449 if (textImporte.getText().equals("")) {
450 lblErrorPrevio.setVisible(true);
452 lblErrorPrevio.setVisible(false);
454 Float importe = Float.parseFloat(textImporte.getText());
455 Float suma = userActualizado.getBalance() + importe;
456 lblSaldoActualizado.setText(suma.toString() + " €");
462 // JButton btnAtras = new JButton(ResourceBundle.getBundle("Etiquetas").getString("Close"));
463 JButton btnAtras = new JButton("Close");
464 btnAtras.setBounds(47, 722, 99, 26);
465 getContentPane().add(btnAtras);
466 btnAtras.setBackground(SystemColor.controlShadow);
467 btnAtras.setForeground(Color.WHITE);
468 btnAtras.setFont(new Font("Dialog", Font.BOLD, 14));
469 panel_1.setBounds(58, 180, 522, 532);
470 getContentPane().add(panel_1);
471 panel_1.setBorder(null);
472 panel_1.setBackground(Color.WHITE);
473 panel_1.setLayout(null);
474 panel_2.setBorder(null);
475 panel_2.setBackground(SystemColor.textHighlight);
476 panel_2.setBounds(0, 0, 522, 363);
477 panel_1.add(panel_2);
478 panel_2.setLayout(null);
479 lblSaldoActual.setBounds(33, 26, 477, 125);
480 panel_2.add(lblSaldoActual);
481 lblSaldoActual.setForeground(Color.WHITE);
482 lblSaldoActual.setFont(new Font("Dialog", Font.BOLD, 75));
483 lblSaldoActual.setText(userlog.getBalance().toString() + " €");
484 lblSaldoActualizado.setBounds(14, 161, 498, 155);
485 panel_2.add(lblSaldoActualizado);
486 lblSaldoActualizado.setForeground(Color.WHITE);
487 lblSaldoActualizado.setFont(new Font("Dialog", Font.BOLD, 75));
488 // lblSaldoActualInfo
489 // .setText(ResourceBundle.getBundle("Etiquetas").getString("RecargarSaldoGUI.lblSaldoActualInfo.text")); //$NON-NLS-1$ //$NON-NLS-2$
490 lblSaldoActualInfo.setText("Saldo actual:"); //$NON-NLS-1$ //$NON-NLS-2$
491 lblSaldoActualInfo.setFont(new Font("Dialog", Font.BOLD, 20));
492 lblSaldoActualInfo.setForeground(Color.WHITE);
493 lblSaldoActualInfo.setBounds(33, 12, 174, 33);
495 panel_2.add(lblSaldoActualInfo);
497 // .setText(ResourceBundle.getBundle("Etiquetas").getString("RecargarSaldoGUI.lblSaldoPrevisto.text")); //$NON-NLS-1$ //$NON-NLS-2$
498 lblSaldoPrevisto.setText("Saldo previsto:"); //$NON-NLS-1$ //$NON-NLS-2$
499 lblSaldoPrevisto.setForeground(Color.WHITE);
500 lblSaldoPrevisto.setFont(new Font("Dialog", Font.BOLD, 20));
501 lblSaldoPrevisto.setBounds(33, 163, 174, 33);
503 panel_2.add(lblSaldoPrevisto);
504 lblUsername.setFont(new Font("Dialog", Font.BOLD, 16));
505 lblUsername.setBounds(296, 402, 119, 22);
506 lblUsername.setText(userlog.getUserName());
508 panel_1.add(lblUsername);
509 lblNombre.setFont(new Font("Dialog", Font.BOLD, 16));
510 lblNombre.setBounds(296, 466, 194, 22);
511 lblNombre.setText(userlog.getFirstName() + " " + userlog.getLastName());
512 panel_1.add(lblNombre);
513 lblNewLabel.setFont(new Font("Dialog", Font.BOLD, 16));
514 lblNewLabel.setBounds(32, 399, 163, 29);
516 panel_1.add(lblNewLabel);
517 lblNewLabel_1.setFont(new Font("Dialog", Font.BOLD, 16));
518 lblNewLabel_1.setBounds(32, 463, 180, 29);
520 panel_1.add(lblNewLabel_1);
522 JSeparator separator_1 = new JSeparator();
523 separator_1.setBounds(32, 448, 446, 6);
524 panel_1.add(separator_1);
525 lblNewLabel_2.setBounds(85, 123, 149, 16);
527 getContentPane().add(lblNewLabel_2);
528 JLabel lblIcono = new JLabel(icon);
529 lblIcono.setBounds(40, 37, 50, 27);
530 getContentPane().add(lblIcono);
532 btnAtras.addActionListener(new ActionListener() {
534 public void actionPerformed(ActionEvent e) {
535 JFrame a = new MainGUI(userActualizado);
536 a.setAlwaysOnTop(true);
542 labelNumTar.setVisible(false);
543 labelCuentaB.setVisible(false);
544 labelCadTar.setVisible(false);
545 labelVerifTar.setVisible(false);
547 if (userlog.getBankAccount().equals("") == false) {
549 textCuentaB.setText(userlog.getBankAccount());
552 textCuentaB.setText("");
558 // acepta cuentas bancarias del tipo: ES23 3434 2342 3423
559 private boolean validoCuentaB(String cuentab) {
560 Pattern pattern = Pattern.compile("^[A-Z]{2}[0-9]{2}\\s[0-9]{4}\\s[0-9]{4}\\s[0-9]{4}$");
561 Matcher mat = pattern.matcher(cuentab);
563 System.out.println("El formato de la cuenta bancaria cumple el formato");
565 System.out.println("El formato de la cuenta bancaria es incorrecto");
571 // acepta tarjetas de credito del tipo: 1111111111111111 o 1111 1111 1111 1111
572 private boolean validoTarjeta(String tarjeta) {
573 Pattern pattern = Pattern.compile("^([0-9]{16}|[0-9]{4}\\s[0-9]{4}\\s[0-9]{4}\\s[0-9]{4})$");
574 Matcher mat = pattern.matcher(tarjeta);
576 System.out.println("El formato de la tarjeta de credito cumple el formato");
578 System.out.println("El formato de la tarjeta de credito es incorrecto");
584 private boolean validoMes(String mes) {
587 Integer mesInt = Integer.parseInt(mes);
588 if (mesInt < 1 || mesInt > 12) {
594 } catch (Exception e) {
600 private boolean validoAño(String año) {
603 Integer añoInt = Integer.parseInt(año);
605 if (añoInt < 21 || añoInt > 28) {
613 } catch (Exception e) {
619 private boolean validoCVC(String cod) {
621 if (cod.charAt(0) == '0') {
622 Integer codInt = Integer.parseInt(cod);
623 int digitos = (int) (Math.log10(codInt) + 1);
630 Integer codInt = Integer.parseInt(cod);
631 int digitos = (int) (Math.log10(codInt) + 1);
639 } catch (Exception e) {