diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 863c43f..f069337 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -6,19 +6,62 @@
+
-
-
-
-
+
+
+
+
-
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -74,96 +117,12 @@
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -181,6 +140,11 @@
+ addRow
+ set
+ print
+ "
+ fec
System
[2018] [Daniel Cortes]
id
@@ -206,11 +170,6 @@
editar
toggleSortOrder
Copyright (c) 2018 Daniel Cortes
- JFormattedTextField(NumberFormat.getCurrencyInstance())
- NumberFormat.getCurrencyInstance(Locale.forLanguageTag("CL"))
- new JFormattedTextField()
- DosMil
- document
2018 Daniel Cortes
@@ -220,8 +179,6 @@
text
integer primary key
Copyright (c) 2018-2019 Daniel Cortes
- JFormattedTextField(NumberFormat.getCurrencyInstance(Locale.forLanguageTag("CL")))
- new JFormattedTextField(formatter)
$PROJECT_DIR$/src
@@ -233,6 +190,9 @@
@@ -338,8 +295,6 @@
-
-
@@ -350,40 +305,14 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
@@ -397,7 +326,7 @@
-
+
@@ -577,12 +506,7 @@
-
-
-
-
-
-
+
1545280618093
@@ -766,25 +690,11 @@
1546536860193
-
- 1546540174373
-
-
-
- 1546540174373
-
-
- 1546540666662
-
-
-
- 1546540666662
-
-
+
-
+
@@ -797,9 +707,8 @@
-
-
+
@@ -808,7 +717,7 @@
-
+
@@ -821,7 +730,7 @@
-
+
@@ -888,6 +797,7 @@
+
@@ -911,22 +821,33 @@
-
-
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
@@ -954,6 +875,13 @@
+
+
+
+
+
+
+
@@ -990,12 +918,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1024,6 +1006,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -1034,6 +1026,134 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1089,6 +1209,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1147,315 +1297,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/dist/caja.jar b/dist/caja.jar
index f07f07a..2c225db 100644
Binary files a/dist/caja.jar and b/dist/caja.jar differ
diff --git a/dist/database.sqlite b/dist/database.sqlite
index 4c5d85d..f3a435e 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 97feebb..77f1f16 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().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());
+ 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()));
}
/**
@@ -252,31 +252,31 @@ public class ArqueoController {
* llama a updateResumenEfectivo y updateResumenArqueo para actualizar los datos en efectivoField y arqueoField
*/
private void guardarEfectivo() {
- int diez = (Integer) this.view.getDiezField().getValue();
- int cincuenta = (Integer) this.view.getCincuentaField().getValue();
- int cien = (Integer) this.view.getCienField().getValue();
- int quinientos = (Integer) this.view.getQuinientosField().getValue();
- int mil = (Integer) this.view.getMilField().getValue();
- int dosMil = (Integer) this.view.getDosMilField().getValue();
- int cincoMil = (Integer) this.view.getCincoMilField().getValue();
- int diezMil = (Integer) this.view.getDiezMilField().getValue();
- int veinteMil = (Integer) this.view.getVeinteMilField().getValue();
+ 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();
- //if (this.validateEfectivoInput(diez, cincuenta, cien, quinientos, mil, dosMil, cincoMil, diezMil, 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);
+ 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.efectivoDAO.updateEfectivo(efectivo);
this.updateResumenEfectivo();
this.updateResumenArqueo();
- //}
+ }
}
/**
diff --git a/src/danielcortes/xyz/views/ArqueoView.form b/src/danielcortes/xyz/views/ArqueoView.form
index 11281ed..25e8ce3 100644
--- a/src/danielcortes/xyz/views/ArqueoView.form
+++ b/src/danielcortes/xyz/views/ArqueoView.form
@@ -188,14 +188,14 @@
-
+
-
+
@@ -206,24 +206,24 @@
-
+
-
+
-
+
-
+
@@ -242,24 +242,24 @@
-
+
-
+
-
+
-
+
@@ -278,14 +278,14 @@
-
+
-
+
@@ -296,14 +296,14 @@
-
+
-
+
@@ -314,14 +314,14 @@
-
+
-
+
@@ -332,14 +332,14 @@
-
+
-
+
diff --git a/src/danielcortes/xyz/views/ArqueoView.java b/src/danielcortes/xyz/views/ArqueoView.java
index c995afb..9dd3f96 100644
--- a/src/danielcortes/xyz/views/ArqueoView.java
+++ b/src/danielcortes/xyz/views/ArqueoView.java
@@ -28,26 +28,22 @@ 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.LimitDocumentFilter;
-import danielcortes.xyz.views.components.NumberFormatFactory;
import javax.swing.*;
import javax.swing.border.TitledBorder;
-import javax.swing.text.AbstractDocument;
import java.awt.*;
-import java.util.ArrayList;
public class ArqueoView {
private JPanel contentPanel;
- private JFormattedTextField veinteMilField;
- private JFormattedTextField diezMilField;
- private JFormattedTextField cincoMilField;
- private JFormattedTextField dosMilField;
- private JFormattedTextField milField;
- private JFormattedTextField quinientosField;
- private JFormattedTextField cienField;
- private JFormattedTextField cincuentaField;
- private JFormattedTextField diezField;
+ 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 JTextField chequesField;
private JTextField tarjetasField;
private JTextField efectivoField;
@@ -71,62 +67,43 @@ public class ArqueoView {
private JTextField diferenciaField;
private JTextField debeRendirField;
- private ArrayList efectivoFieldList;
-
- public ArqueoView() {
- $$$setupUI$$$();
-
- this.efectivoFieldList = new ArrayList<>();
- this.efectivoFieldList.add(this.veinteMilField);
- this.efectivoFieldList.add(this.diezMilField);
- this.efectivoFieldList.add(this.cincoMilField);
- this.efectivoFieldList.add(this.dosMilField);
- this.efectivoFieldList.add(this.milField);
- this.efectivoFieldList.add(this.quinientosField);
- this.efectivoFieldList.add(this.cienField);
- this.efectivoFieldList.add(this.cincuentaField);
- this.efectivoFieldList.add(this.diezField);
-
- this.setupFields();
- }
-
public JPanel getContentPanel() {
return contentPanel;
}
- public JFormattedTextField getVeinteMilField() {
+ public JTextField getVeinteMilField() {
return veinteMilField;
}
- public JFormattedTextField getDiezMilField() {
+ public JTextField getDiezMilField() {
return diezMilField;
}
- public JFormattedTextField getCincoMilField() {
+ public JTextField getCincoMilField() {
return cincoMilField;
}
- public JFormattedTextField getDosMilField() {
+ public JTextField getDosMilField() {
return dosMilField;
}
- public JFormattedTextField getMilField() {
+ public JTextField getMilField() {
return milField;
}
- public JFormattedTextField getQuinientosField() {
+ public JTextField getQuinientosField() {
return quinientosField;
}
- public JFormattedTextField getCienField() {
+ public JTextField getCienField() {
return cienField;
}
- public JFormattedTextField getCincuentaField() {
+ public JTextField getCincuentaField() {
return cincuentaField;
}
- public JFormattedTextField getDiezField() {
+ public JTextField getDiezField() {
return diezField;
}
@@ -218,6 +195,13 @@ public class ArqueoView {
return errorTarjetas;
}
+ {
+// GUI initializer generated by IntelliJ IDEA GUI Designer
+// >>> IMPORTANT!! <<<
+// DO NOT EDIT OR ADD ANY CODE HERE!
+ $$$setupUI$$$();
+ }
+
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
@@ -299,17 +283,17 @@ public class ArqueoView {
final JLabel label8 = new JLabel();
label8.setText("$20000");
panel3.add(label8, 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 JFormattedTextField();
- veinteMilField.setText("");
+ veinteMilField = new JTextField();
+ veinteMilField.setText("0");
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 label9 = new JLabel();
label9.setText("$10000");
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));
- diezMilField = new JFormattedTextField();
- diezMilField.setText("");
+ 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 JFormattedTextField();
- cincoMilField.setText("");
+ 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));
final JLabel label10 = new JLabel();
label10.setText("$5000");
@@ -317,11 +301,11 @@ public class ArqueoView {
final JLabel label11 = new JLabel();
label11.setText("$2000");
panel3.add(label11, 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 JFormattedTextField();
- dosMilField.setText("");
+ 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 JFormattedTextField();
- milField.setText("");
+ 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));
final JLabel label12 = new JLabel();
label12.setText("$1000");
@@ -329,26 +313,26 @@ public class ArqueoView {
final JLabel label13 = new JLabel();
label13.setText("$500");
panel3.add(label13, 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 JFormattedTextField();
- quinientosField.setText("");
+ 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));
final JLabel label14 = new JLabel();
label14.setText("$100");
panel3.add(label14, 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 JFormattedTextField();
- cienField.setText("");
+ 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));
final JLabel label15 = new JLabel();
label15.setText("$50");
panel3.add(label15, 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 JFormattedTextField();
- cincuentaField.setText("");
+ 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));
final JLabel label16 = new JLabel();
label16.setText("$10");
panel3.add(label16, 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 JFormattedTextField();
- diezField.setText("");
+ 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));
guardarEfectivoButton = new JButton();
guardarEfectivoButton.setText("Guardar");
@@ -457,10 +441,4 @@ public class ArqueoView {
return contentPanel;
}
- private void setupFields() {
- for (JFormattedTextField formattedTextField : this.efectivoFieldList) {
- formattedTextField.setFormatterFactory(new NumberFormatFactory());
- ((AbstractDocument) formattedTextField.getDocument()).setDocumentFilter(new LimitDocumentFilter(9));
- }
- }
}
diff --git a/src/danielcortes/xyz/views/components/LimitDocumentFilter.java b/src/danielcortes/xyz/views/components/LimitDocumentFilter.java
deleted file mode 100644
index 4752e18..0000000
--- a/src/danielcortes/xyz/views/components/LimitDocumentFilter.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.DocumentFilter;
-
-public class LimitDocumentFilter extends DocumentFilter {
-
- private int limit;
-
- public LimitDocumentFilter(int limit) {
- if (limit <= 0) {
- throw new IllegalArgumentException("Limit can not be <= 0");
- }
- this.limit = limit;
- }
-
- @Override
- public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
- int currentLength = fb.getDocument().getLength();
- int overLimit = (currentLength + text.length()) - limit - length;
- if (overLimit > 0) {
- text = text.substring(0, text.length() - overLimit);
- }
- if (text.length() > 0) {
- super.replace(fb, offset, length, text, attrs);
- }
- }
-
-}
diff --git a/src/danielcortes/xyz/views/components/NumberFormatFactory.java b/src/danielcortes/xyz/views/components/NumberFormatFactory.java
deleted file mode 100644
index 4c4098b..0000000
--- a/src/danielcortes/xyz/views/components/NumberFormatFactory.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.text.DefaultFormatterFactory;
-import javax.swing.text.NumberFormatter;
-import java.text.NumberFormat;
-
-public class NumberFormatFactory extends DefaultFormatterFactory {
- public NumberFormatFactory() {
- super();
- NumberFormat pnDisplayFormat = NumberFormat.getIntegerInstance();
- pnDisplayFormat.setMinimumIntegerDigits(1);
- pnDisplayFormat.setMaximumIntegerDigits(9);
- NumberFormatter displayFormatter = new NumberFormatter(pnDisplayFormat);
- displayFormatter.setValueClass(Integer.class);
-
- NumberFormat pnEditFormat = NumberFormat.getIntegerInstance();
- pnEditFormat.setMinimumIntegerDigits(1);
- pnEditFormat.setMaximumIntegerDigits(9);
-
- NumberFormatter editFormatter = new NumberFormatter(pnEditFormat);
- editFormatter.setValueClass(Integer.class);
-
- this.setDefaultFormatter(displayFormatter);
- this.setDisplayFormatter(displayFormatter);
- this.setEditFormatter(editFormatter);
- }
-}