Revert "Cambiados fields de efectivo por JFormattedtextfields y son formateados como numeros"
This reverts commit 1647e6c9f4.
Volviendo a un estado anterior por problemas con los cambios sobre
jformatedtextfield, se usara otra estrategia
This commit is contained in:
@@ -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();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -188,14 +188,14 @@
|
||||
<text value="$20000"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="ce2b2" class="javax.swing.JFormattedTextField" binding="veinteMilField">
|
||||
<component id="99f2e" class="javax.swing.JTextField" binding="veinteMilField">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="200" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
<text value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="584ed" class="javax.swing.JLabel">
|
||||
@@ -206,24 +206,24 @@
|
||||
<text value="$10000"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="5b2c6" class="javax.swing.JFormattedTextField" binding="diezMilField">
|
||||
<component id="5431d" class="javax.swing.JTextField" binding="diezMilField">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="200" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
<text value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="89afe" class="javax.swing.JFormattedTextField" binding="cincoMilField">
|
||||
<component id="af49b" class="javax.swing.JTextField" binding="cincoMilField">
|
||||
<constraints>
|
||||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="200" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
<text value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="8d468" class="javax.swing.JLabel">
|
||||
@@ -242,24 +242,24 @@
|
||||
<text value="$2000"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="de893" class="javax.swing.JFormattedTextField" binding="dosMilField">
|
||||
<component id="bbb4" class="javax.swing.JTextField" binding="dosMilField">
|
||||
<constraints>
|
||||
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="200" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
<text value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="bd2a0" class="javax.swing.JFormattedTextField" binding="milField">
|
||||
<component id="4807e" class="javax.swing.JTextField" binding="milField">
|
||||
<constraints>
|
||||
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="200" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
<text value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e80c8" class="javax.swing.JLabel">
|
||||
@@ -278,14 +278,14 @@
|
||||
<text value="$500"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="63aff" class="javax.swing.JFormattedTextField" binding="quinientosField">
|
||||
<component id="3d6c3" class="javax.swing.JTextField" binding="quinientosField">
|
||||
<constraints>
|
||||
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="200" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
<text value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7910b" class="javax.swing.JLabel">
|
||||
@@ -296,14 +296,14 @@
|
||||
<text value="$100"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4ea8f" class="javax.swing.JFormattedTextField" binding="cienField">
|
||||
<component id="8f6e8" class="javax.swing.JTextField" binding="cienField">
|
||||
<constraints>
|
||||
<grid row="12" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="200" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
<text value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e105f" class="javax.swing.JLabel">
|
||||
@@ -314,14 +314,14 @@
|
||||
<text value="$50"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="2e4ef" class="javax.swing.JFormattedTextField" binding="cincuentaField">
|
||||
<component id="22b2c" class="javax.swing.JTextField" binding="cincuentaField">
|
||||
<constraints>
|
||||
<grid row="14" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="200" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
<text value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="fcf59" class="javax.swing.JLabel">
|
||||
@@ -332,14 +332,14 @@
|
||||
<text value="$10"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="642a1" class="javax.swing.JFormattedTextField" binding="diezField">
|
||||
<component id="6f156" class="javax.swing.JTextField" binding="diezField">
|
||||
<constraints>
|
||||
<grid row="16" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="200" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
<text value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a2c3f" class="javax.swing.JButton" binding="guardarEfectivoButton">
|
||||
|
||||
@@ -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<JFormattedTextField> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user