diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index f0f9c3b..d93b832 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -10,20 +10,14 @@
-
-
-
+
+
-
-
-
-
-
-
-
+
+
+
-
@@ -79,10 +73,112 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -98,8 +194,6 @@
- addRow
- set
print
"
fec
@@ -128,6 +222,8 @@
editar
toggleSortOrder
Copyright (c) 2018 Daniel Cortes
+ format
+ format(
2018 Daniel Cortes
@@ -148,8 +244,6 @@
@@ -253,8 +349,6 @@
-
-
@@ -293,7 +387,7 @@
-
+
@@ -304,6 +398,8 @@
+
+
@@ -317,7 +413,7 @@
-
+
@@ -498,7 +594,8 @@
-
+
+
1545280618093
@@ -689,11 +786,18 @@
1546720253879
-
+
+ 1546722949902
+
+
+
+ 1546722949902
+
+
-
+
@@ -711,7 +815,7 @@
-
+
@@ -797,7 +901,6 @@
-
@@ -822,15 +925,14 @@
-
+
+
-
-
@@ -1118,90 +1220,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1403,6 +1421,148 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dist/caja.jar b/dist/caja.jar
index 460f489..af6a52b 100644
Binary files a/dist/caja.jar and b/dist/caja.jar differ
diff --git a/dist/database.sqlite b/dist/database.sqlite
index 2aaa967..4f54561 100644
Binary files a/dist/database.sqlite and b/dist/database.sqlite differ
diff --git a/src/danielcortes/xyz/controllers/ArqueoController.java b/src/danielcortes/xyz/controllers/ArqueoController.java
index 71d406d..ba10ccc 100644
--- a/src/danielcortes/xyz/controllers/ArqueoController.java
+++ b/src/danielcortes/xyz/controllers/ArqueoController.java
@@ -90,15 +90,15 @@ public class ArqueoController {
*/
private void fillEfectivo() {
this.efectivo = this.efectivoDAO.findByCaja(this.caja);
- this.view.getVeinteMilField().setText(String.valueOf(efectivo.getVeinteMil()));
- this.view.getDiezMilField().setText(String.valueOf(efectivo.getDiezMil()));
- this.view.getCincoMilField().setText(String.valueOf(efectivo.getCincoMil()));
- this.view.getDosMilField().setText(String.valueOf(efectivo.getDosMil()));
- this.view.getMilField().setText(String.valueOf(efectivo.getMil()));
- this.view.getQuinientosField().setText(String.valueOf(efectivo.getQuinientos()));
- this.view.getCienField().setText(String.valueOf(efectivo.getCien()));
- this.view.getCincuentaField().setText(String.valueOf(efectivo.getCincuenta()));
- this.view.getDiezField().setText(String.valueOf(efectivo.getDiez()));
+ this.view.getVeinteMilField().setValue(efectivo.getVeinteMil());
+ this.view.getDiezMilField().setValue(efectivo.getDiezMil());
+ this.view.getCincoMilField().setValue(efectivo.getCincoMil());
+ this.view.getDosMilField().setValue(efectivo.getDosMil());
+ this.view.getMilField().setValue(efectivo.getMil());
+ this.view.getQuinientosField().setValue(efectivo.getQuinientos());
+ this.view.getCienField().setValue(efectivo.getCien());
+ this.view.getCincuentaField().setValue(efectivo.getCincuenta());
+ this.view.getDiezField().setValue(efectivo.getDiez());
}
/**
@@ -223,8 +223,7 @@ public class ArqueoController {
* Primero llama a normalizar el input, luego a esconder los mensajes de error, para finalmente llamar a guardar el efectivo
*/
private void guardarEfectivoActionListener(){
- this.normalizeEfectivoInput();
- this.hiddeEfectivoErrorMessages();
+ this.view.getGuardarEfectivoButton().requestFocus();
this.guardarEfectivo();
}
@@ -243,31 +242,29 @@ public class ArqueoController {
* llama a updateResumenEfectivo y updateResumenArqueo para actualizar los datos en efectivoField y arqueoField
*/
private void guardarEfectivo() {
- String diez = this.view.getDiezField().getText();
- String cincuenta = this.view.getCincuentaField().getText();
- String cien = this.view.getCienField().getText();
- String quinientos = this.view.getQuinientosField().getText();
- String mil = this.view.getMilField().getText();
- String dosMil = this.view.getDosMilField().getText();
- String cincoMil = this.view.getCincoMilField().getText();
- String diezMil = this.view.getDiezMilField().getText();
- String veinteMil = this.view.getVeinteMilField().getText();
+ int diez = this.view.getDiezField().getValue();
+ int cincuenta = this.view.getCincuentaField().getValue();
+ int cien = this.view.getCienField().getValue();
+ int quinientos = this.view.getQuinientosField().getValue();
+ int mil = this.view.getMilField().getValue();
+ int dosMil = this.view.getDosMilField().getValue();
+ int cincoMil = this.view.getCincoMilField().getValue();
+ int diezMil = this.view.getDiezMilField().getValue();
+ int veinteMil = this.view.getVeinteMilField().getValue();
- if (this.validateEfectivoInput(diez, cincuenta, cien, quinientos, mil, dosMil, cincoMil, diezMil, veinteMil)) {
- this.efectivo.setDiez(Integer.valueOf(diez));
- this.efectivo.setCincuenta(Integer.valueOf(cincuenta));
- this.efectivo.setCien(Integer.valueOf(cien));
- this.efectivo.setQuinientos(Integer.valueOf(quinientos));
- this.efectivo.setMil(Integer.valueOf(mil));
- this.efectivo.setDosMil(Integer.valueOf(dosMil));
- this.efectivo.setCincoMil(Integer.valueOf(cincoMil));
- this.efectivo.setDiezMil(Integer.valueOf(diezMil));
- this.efectivo.setVeinteMil(Integer.valueOf(veinteMil));
+ this.efectivo.setDiez(diez);
+ this.efectivo.setCincuenta(cincuenta);
+ this.efectivo.setCien(cien);
+ this.efectivo.setQuinientos(quinientos);
+ this.efectivo.setMil(mil);
+ this.efectivo.setDosMil(dosMil);
+ this.efectivo.setCincoMil(cincoMil);
+ this.efectivo.setDiezMil(diezMil);
+ this.efectivo.setVeinteMil(veinteMil);
this.efectivoDAO.updateEfectivo(efectivo);
this.updateResumenEfectivo();
this.updateResumenArqueo();
- }
}
/**
@@ -288,25 +285,6 @@ public class ArqueoController {
}
}
- /**
- * Llama a las validaciones necesarias para el input de Efectivo
- * @return si es que paso todas las validaciones.
- */
- private boolean validateEfectivoInput(String diez, String cincuenta, String cien, String quinientos, String mil, String dosMil, String cincoMil, String diezMil, String veinteMil) {
-
- boolean diezValidation = validateEfectivoMoneda(diez, this.view.getErrorDiez());
- boolean cincuentaValidation = validateEfectivoMoneda(cincuenta, this.view.getErrorCincuenta());
- boolean cienValidation = validateEfectivoMoneda(cien, this.view.getErrorCien());
- boolean quinientosValidation = validateEfectivoMoneda(quinientos, this.view.getErrorQuinientos());
- boolean milValidation = validateEfectivoMoneda(mil, this.view.getErrorMil());
- boolean dosMilValidation = validateEfectivoMoneda(dosMil, this.view.getErrorDosMil());
- boolean cincoMilValidation = validateEfectivoMoneda(cincoMil, this.view.getErrorCincoMil());
- boolean diezMilValidation = validateEfectivoMoneda(diezMil, this.view.getErrorDiezMil());
- boolean veinteMilValidation = validateEfectivoMoneda(veinteMil, this.view.getErrorVeinteMil());
-
- return diezValidation && cincuentaValidation && cienValidation && quinientosValidation && milValidation && dosMilValidation && cincoMilValidation && diezMilValidation && veinteMilValidation;
- }
-
/**
* Llama a las validaciones necesarias el input de Documentos
* @return si es que todas las validaciones fueron correctas
@@ -319,43 +297,6 @@ public class ArqueoController {
return tarjetasValidation && chequesValidation;
}
- /**
- * Valida el valor entregado contra las siguientes pruebas
- * - Es null
- * - Esta vacio
- * - Los caracteres no son solamente digitos
- * - El largo es mayor que diez
- * Setea un mensaje de error correspondiente en el errorLabel entregado.
- * @return cuando cualquiera de los casos anteriores sea true se retorna falso, si no retorna true.
- */
- private boolean validateEfectivoMoneda(String valor, JLabel errorLabel) {
- if (valor == null) {
- errorLabel.setText("Hubo un problema con los datos");
- errorLabel.setVisible(true);
- return false;
- }
-
- if (valor.isEmpty()) {
- errorLabel.setText("El campo esta vacio");
- errorLabel.setVisible(true);
- return false;
- }
-
- if (!valor.chars().allMatch(Character::isDigit)) {
- errorLabel.setText("Deben ser numeros");
- errorLabel.setVisible(true);
- return false;
- }
-
- if (valor.length() > 10) {
- errorLabel.setText("El numero ingresado es demasiado largo");
- errorLabel.setVisible(true);
- return false;
- }
-
- return true;
- }
-
/**
* Valida el valor entregado contra las siguientes pruebas
* - Es null
@@ -394,21 +335,6 @@ public class ArqueoController {
return true;
}
- /**
- * Esconde los mensajes de error de los campos de efectivo
- */
- private void hiddeEfectivoErrorMessages() {
- this.view.getErrorDiez().setVisible(false);
- this.view.getErrorCincuenta().setVisible(false);
- this.view.getErrorCien().setVisible(false);
- this.view.getErrorQuinientos().setVisible(false);
- this.view.getErrorMil().setVisible(false);
- this.view.getErrorDosMil().setVisible(false);
- this.view.getErrorCincoMil().setVisible(false);
- this.view.getErrorDiezMil().setVisible(false);
- this.view.getErrorVeinteMil().setVisible(false);
- }
-
/**
* Esconde los mensajes de error en los campos de documentos
*/
@@ -417,21 +343,6 @@ public class ArqueoController {
this.view.getErrorCheques().setVisible(false);
}
- /**
- * Ejecuta trim sobre todos los campos de efectivo
- */
- private void normalizeEfectivoInput() {
- this.view.getDiezField().setText(this.view.getDiezField().getText().trim());
- this.view.getCincuentaField().setText(this.view.getCincuentaField().getText().trim());
- this.view.getCienField().setText(this.view.getCienField().getText().trim());
- this.view.getQuinientosField().setText(this.view.getQuinientosField().getText().trim());
- this.view.getMilField().setText(this.view.getMilField().getText().trim());
- this.view.getDosMilField().setText(this.view.getDosMilField().getText().trim());
- this.view.getCincoMilField().setText(this.view.getCincoMilField().getText().trim());
- this.view.getDiezMilField().setText(this.view.getDiezMilField().getText().trim());
- this.view.getVeinteMilField().setText(this.view.getVeinteMilField().getText().trim());
- }
-
/**
* Ejecuta trim sobre todos los campos de documentos
*/
diff --git a/src/danielcortes/xyz/views/ArqueoView.form b/src/danielcortes/xyz/views/ArqueoView.form
index a4a0b83..1c33ac3 100644
--- a/src/danielcortes/xyz/views/ArqueoView.form
+++ b/src/danielcortes/xyz/views/ArqueoView.form
@@ -1,6 +1,6 @@
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
-
+
@@ -217,35 +217,35 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -253,79 +253,79 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -333,96 +333,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -505,7 +415,7 @@
-
+
diff --git a/src/danielcortes/xyz/views/ArqueoView.java b/src/danielcortes/xyz/views/ArqueoView.java
index 427c0ab..13af181 100644
--- a/src/danielcortes/xyz/views/ArqueoView.java
+++ b/src/danielcortes/xyz/views/ArqueoView.java
@@ -28,6 +28,7 @@ package danielcortes.xyz.views;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
+import danielcortes.xyz.views.components.NumberFormatedTextField;
import javax.swing.*;
import javax.swing.border.TitledBorder;
@@ -35,15 +36,15 @@ import java.awt.*;
public class ArqueoView {
private JPanel contentPanel;
- private JTextField veinteMilField;
- private JTextField diezMilField;
- private JTextField cincoMilField;
- private JTextField dosMilField;
- private JTextField milField;
- private JTextField quinientosField;
- private JTextField cienField;
- private JTextField cincuentaField;
- private JTextField diezField;
+ private NumberFormatedTextField veinteMilField;
+ private NumberFormatedTextField diezMilField;
+ private NumberFormatedTextField cincoMilField;
+ private NumberFormatedTextField dosMilField;
+ private NumberFormatedTextField milField;
+ private NumberFormatedTextField quinientosField;
+ private NumberFormatedTextField cienField;
+ private NumberFormatedTextField cincuentaField;
+ private NumberFormatedTextField diezField;
private JTextField chequesField;
private JTextField tarjetasField;
private JTextField efectivoField;
@@ -52,15 +53,6 @@ public class ArqueoView {
private JTextField rendidoField;
private JButton guardarEfectivoButton;
private JButton guardarDocumentosButton;
- private JLabel errorVeinteMil;
- private JLabel errorDiezMil;
- private JLabel errorCincoMil;
- private JLabel errorDosMil;
- private JLabel errorMil;
- private JLabel errorQuinientos;
- private JLabel errorCien;
- private JLabel errorCincuenta;
- private JLabel errorDiez;
private JLabel errorCheques;
private JLabel errorTarjetas;
private JTextField diferenciaField;
@@ -70,39 +62,39 @@ public class ArqueoView {
return contentPanel;
}
- public JTextField getVeinteMilField() {
+ public NumberFormatedTextField getVeinteMilField() {
return veinteMilField;
}
- public JTextField getDiezMilField() {
+ public NumberFormatedTextField getDiezMilField() {
return diezMilField;
}
- public JTextField getCincoMilField() {
+ public NumberFormatedTextField getCincoMilField() {
return cincoMilField;
}
- public JTextField getDosMilField() {
+ public NumberFormatedTextField getDosMilField() {
return dosMilField;
}
- public JTextField getMilField() {
+ public NumberFormatedTextField getMilField() {
return milField;
}
- public JTextField getQuinientosField() {
+ public NumberFormatedTextField getQuinientosField() {
return quinientosField;
}
- public JTextField getCienField() {
+ public NumberFormatedTextField getCienField() {
return cienField;
}
- public JTextField getCincuentaField() {
+ public NumberFormatedTextField getCincuentaField() {
return cincuentaField;
}
- public JTextField getDiezField() {
+ public NumberFormatedTextField getDiezField() {
return diezField;
}
@@ -130,14 +122,6 @@ public class ArqueoView {
return rendidoField;
}
- public JTextField getDebeRendirField() {
- return debeRendirField;
- }
-
- public JTextField getDiferenciaField() {
- return diferenciaField;
- }
-
public JButton getGuardarEfectivoButton() {
return guardarEfectivoButton;
}
@@ -146,42 +130,6 @@ public class ArqueoView {
return guardarDocumentosButton;
}
- public JLabel getErrorVeinteMil() {
- return errorVeinteMil;
- }
-
- public JLabel getErrorDiezMil() {
- return errorDiezMil;
- }
-
- public JLabel getErrorCincoMil() {
- return errorCincoMil;
- }
-
- public JLabel getErrorDosMil() {
- return errorDosMil;
- }
-
- public JLabel getErrorMil() {
- return errorMil;
- }
-
- public JLabel getErrorQuinientos() {
- return errorQuinientos;
- }
-
- public JLabel getErrorCien() {
- return errorCien;
- }
-
- public JLabel getErrorCincuenta() {
- return errorCincuenta;
- }
-
- public JLabel getErrorDiez() {
- return errorDiez;
- }
-
public JLabel getErrorCheques() {
return errorCheques;
}
@@ -190,6 +138,14 @@ public class ArqueoView {
return errorTarjetas;
}
+ public JTextField getDiferenciaField() {
+ return diferenciaField;
+ }
+
+ public JTextField getDebeRendirField() {
+ return debeRendirField;
+ }
+
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
@@ -206,7 +162,7 @@ public class ArqueoView {
*/
private void $$$setupUI$$$() {
contentPanel = new JPanel();
- contentPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
+ contentPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(7, 2, new Insets(10, 10, 10, 10), -1, -1));
contentPanel.add(panel1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
@@ -263,113 +219,68 @@ public class ArqueoView {
panel1.add(efectivoField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
- contentPanel.add(panel2, new GridConstraints(0, 0, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ contentPanel.add(panel2, new GridConstraints(0, 0, 3, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final JPanel panel3 = new JPanel();
- panel3.setLayout(new GridLayoutManager(19, 2, new Insets(10, 10, 10, 10), -1, -1));
+ panel3.setLayout(new GridLayoutManager(10, 2, new Insets(10, 10, 10, 10), -1, -1));
panel2.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
panel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Detalle Efectivo", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, -1, -1, panel3.getFont())));
final JLabel label7 = new JLabel();
label7.setText("$20000");
panel3.add(label7, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- veinteMilField = new JTextField();
- veinteMilField.setText("0");
+ veinteMilField = new NumberFormatedTextField();
+ veinteMilField.setText("");
panel3.add(veinteMilField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
final JLabel label8 = new JLabel();
label8.setText("$10000");
- panel3.add(label8, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- diezMilField = new JTextField();
- diezMilField.setText("0");
- panel3.add(diezMilField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
- cincoMilField = new JTextField();
- cincoMilField.setText("0");
- panel3.add(cincoMilField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
+ panel3.add(label8, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ diezMilField = new NumberFormatedTextField();
+ diezMilField.setText("");
+ panel3.add(diezMilField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
+ cincoMilField = new NumberFormatedTextField();
+ cincoMilField.setText("");
+ panel3.add(cincoMilField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
final JLabel label9 = new JLabel();
label9.setText("$5000");
- panel3.add(label9, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ panel3.add(label9, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label10 = new JLabel();
label10.setText("$2000");
- panel3.add(label10, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- dosMilField = new JTextField();
- dosMilField.setText("0");
- panel3.add(dosMilField, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
- milField = new JTextField();
- milField.setText("0");
- panel3.add(milField, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
+ panel3.add(label10, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ dosMilField = new NumberFormatedTextField();
+ dosMilField.setText("");
+ panel3.add(dosMilField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
+ milField = new NumberFormatedTextField();
+ milField.setText("");
+ panel3.add(milField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
final JLabel label11 = new JLabel();
label11.setText("$1000");
- panel3.add(label11, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ panel3.add(label11, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label12 = new JLabel();
label12.setText("$500");
- panel3.add(label12, new GridConstraints(10, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- quinientosField = new JTextField();
- quinientosField.setText("0");
- panel3.add(quinientosField, new GridConstraints(10, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
+ panel3.add(label12, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ quinientosField = new NumberFormatedTextField();
+ quinientosField.setText("");
+ panel3.add(quinientosField, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
final JLabel label13 = new JLabel();
label13.setText("$100");
- panel3.add(label13, new GridConstraints(12, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- cienField = new JTextField();
- cienField.setText("0");
- panel3.add(cienField, new GridConstraints(12, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
+ panel3.add(label13, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ cienField = new NumberFormatedTextField();
+ cienField.setText("");
+ panel3.add(cienField, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
final JLabel label14 = new JLabel();
label14.setText("$50");
- panel3.add(label14, new GridConstraints(14, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- cincuentaField = new JTextField();
- cincuentaField.setText("0");
- panel3.add(cincuentaField, new GridConstraints(14, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
+ panel3.add(label14, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ cincuentaField = new NumberFormatedTextField();
+ cincuentaField.setText("");
+ panel3.add(cincuentaField, new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
final JLabel label15 = new JLabel();
label15.setText("$10");
- panel3.add(label15, new GridConstraints(16, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- diezField = new JTextField();
- diezField.setText("0");
- panel3.add(diezField, new GridConstraints(16, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
+ panel3.add(label15, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ diezField = new NumberFormatedTextField();
+ diezField.setText("");
+ panel3.add(diezField, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
guardarEfectivoButton = new JButton();
guardarEfectivoButton.setText("Guardar");
- panel3.add(guardarEfectivoButton, new GridConstraints(18, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
- errorVeinteMil = new JLabel();
- errorVeinteMil.setForeground(new Color(-65536));
- errorVeinteMil.setText("Error");
- errorVeinteMil.setVisible(false);
- panel3.add(errorVeinteMil, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- errorDiezMil = new JLabel();
- errorDiezMil.setForeground(new Color(-65536));
- errorDiezMil.setText("Error");
- errorDiezMil.setVisible(false);
- panel3.add(errorDiezMil, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- errorCincoMil = new JLabel();
- errorCincoMil.setForeground(new Color(-65536));
- errorCincoMil.setText("Error");
- errorCincoMil.setVisible(false);
- panel3.add(errorCincoMil, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- errorDosMil = new JLabel();
- errorDosMil.setForeground(new Color(-65536));
- errorDosMil.setText("Error");
- errorDosMil.setVisible(false);
- panel3.add(errorDosMil, new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- errorMil = new JLabel();
- errorMil.setForeground(new Color(-65536));
- errorMil.setText("Error");
- errorMil.setVisible(false);
- panel3.add(errorMil, new GridConstraints(9, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- errorQuinientos = new JLabel();
- errorQuinientos.setForeground(new Color(-65536));
- errorQuinientos.setText("Error");
- errorQuinientos.setVisible(false);
- panel3.add(errorQuinientos, new GridConstraints(11, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- errorCien = new JLabel();
- errorCien.setForeground(new Color(-65536));
- errorCien.setText("Error");
- errorCien.setVisible(false);
- panel3.add(errorCien, new GridConstraints(13, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- errorCincuenta = new JLabel();
- errorCincuenta.setForeground(new Color(-65536));
- errorCincuenta.setText("Error");
- errorCincuenta.setVisible(false);
- panel3.add(errorCincuenta, new GridConstraints(15, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- errorDiez = new JLabel();
- errorDiez.setForeground(new Color(-65536));
- errorDiez.setText("Error");
- errorDiez.setVisible(false);
- panel3.add(errorDiez, new GridConstraints(17, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ panel3.add(guardarEfectivoButton, new GridConstraints(9, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
final JPanel panel4 = new JPanel();
panel4.setLayout(new GridLayoutManager(5, 2, new Insets(10, 10, 10, 10), -1, -1));
panel2.add(panel4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
@@ -400,7 +311,7 @@ public class ArqueoView {
errorTarjetas.setVisible(false);
panel4.add(errorTarjetas, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
- contentPanel.add(spacer1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
+ contentPanel.add(spacer1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
}
/**
diff --git a/src/danielcortes/xyz/views/IngresosView.java b/src/danielcortes/xyz/views/IngresosView.java
index 125e8aa..0f2a86c 100644
--- a/src/danielcortes/xyz/views/IngresosView.java
+++ b/src/danielcortes/xyz/views/IngresosView.java
@@ -186,10 +186,10 @@ public class IngresosView {
valorField = new JTextField();
panel2.add(valorField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
final JLabel label3 = new JLabel();
- label3.setText("N° Boleta Inicial");
+ label3.setText("N° Inicial");
panel2.add(label3, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label4 = new JLabel();
- label4.setText("N° Boleta Final");
+ label4.setText("N° Final");
panel2.add(label4, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
nroInicialField = new JTextField();
panel2.add(nroInicialField, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
diff --git a/src/danielcortes/xyz/views/components/NumberFormatedTextField.java b/src/danielcortes/xyz/views/components/NumberFormatedTextField.java
new file mode 100644
index 0000000..16bac11
--- /dev/null
+++ b/src/danielcortes/xyz/views/components/NumberFormatedTextField.java
@@ -0,0 +1,116 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2018-2019 Daniel Cortes
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package danielcortes.xyz.views.components;
+
+import javax.swing.*;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.text.NumberFormat;
+import java.text.ParseException;
+
+public class NumberFormatedTextField extends JTextField {
+ private int value;
+ private NumberFormat nf;
+
+ public NumberFormatedTextField() {
+ super();
+
+ this.nf = NumberFormat.getIntegerInstance();
+
+ this.addFocusListener(new FieldFocusListener());
+ this.addKeyListener(new FieldKeyAdapter());
+ }
+
+ public void setValue(int value){
+ this.value = value;
+ this.setText(nf.format(value));
+ }
+
+ public int getValue(){
+ return this.value;
+ }
+
+ private void readValue(){
+ try {
+ String currentText = this.getText();
+ if(currentText.length() > 0){
+ this.value = nf.parse(currentText).intValue();
+ }
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void formatText(){
+ this.setText(nf.format(this.value));
+ }
+
+ private class FieldFocusListener implements FocusListener{
+ /**
+ * Selecciona todo al momento de ganar foco
+ */
+ @Override
+ public void focusGained(FocusEvent e) {
+ NumberFormatedTextField.this.select(0, getText().length());
+ }
+
+ /**
+ * Actualiza el texto y el valor interno al perder el foco
+ */
+ @Override
+ public void focusLost(FocusEvent e) {
+ NumberFormatedTextField.this.readValue();
+ NumberFormatedTextField.this.formatText();
+ }
+ }
+
+ private class FieldKeyAdapter extends KeyAdapter{
+
+ /**
+ * Solo permitir introducir un maximo de 9 digitos
+ */
+ @Override
+ public void keyTyped(KeyEvent e) {
+ String currentText = NumberFormatedTextField.this.getText();
+ int parsedText = 0;
+
+ if(currentText.length() > 0) {
+ try {
+ parsedText = nf.parse(currentText).intValue();
+ } catch (ParseException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ int length = String.valueOf(parsedText).length();
+
+ if (length >= 9) {
+ e.consume();
+ }
+ }
+ }
+}