Skip to content

Commit

Permalink
Adicionado mascára de formatação no campo PREÇO na tela cadastro de p…
Browse files Browse the repository at this point in the history
…roduto
  • Loading branch information
DanielF-Cardoso committed Jun 19, 2024
1 parent defea30 commit ccec985
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.idea/
target/
.config.properties
src/main/resources/config.properties
14 changes: 7 additions & 7 deletions src/main/java/br/com/pethub/view/ProductsScreen.form
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel19" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="priceField" min="-2" pref="76" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
<Component id="priceField" min="-2" pref="77" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel21" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbSuppliers" min="-2" pref="136" max="-2" attributes="0"/>
Expand All @@ -263,7 +263,7 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="34" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel20" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="stock_qtyField" alignment="3" min="-2" max="-2" attributes="0"/>
Expand Down Expand Up @@ -341,15 +341,15 @@
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value=""/>
</AuxValues>
</Component>
<Component class="javax.swing.JTextField" name="priceField">
<Component class="javax.swing.JFormattedTextField" name="priceField">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="89" green="4a" red="1c" type="rgb"/>
</Property>
<Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.editors.AbstractFormatterFactoryEditor" preCode="try {" postCode="} catch (java.text.ParseException ex) {&#xa;ex.printStackTrace();&#xa;}">
<Format format="##.##" subtype="-1" type="5"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="priceFieldActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
Expand Down
24 changes: 10 additions & 14 deletions src/main/java/br/com/pethub/view/ProductsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void initComponents() {
jLabel20 = new javax.swing.JLabel();
jLabel21 = new javax.swing.JLabel();
cbSuppliers = new javax.swing.JComboBox();
priceField = new javax.swing.JTextField();
priceField = new javax.swing.JFormattedTextField();
productField = new javax.swing.JTextField();
jPanel3 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
Expand Down Expand Up @@ -184,11 +184,11 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
});

priceField.setForeground(new java.awt.Color(28, 74, 137));
priceField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
priceFieldActionPerformed(evt);
}
});
try {
priceField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.##")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}

javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
Expand All @@ -202,8 +202,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel19)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(priceField, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(7, 7, 7)
.addComponent(priceField, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel21)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbSuppliers, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
Expand All @@ -212,7 +212,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGap(34, 34, 34)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel20)
.addComponent(stock_qtyField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
Expand Down Expand Up @@ -530,10 +530,6 @@ private void searchFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:eve
}
}//GEN-LAST:event_searchFieldKeyPressed

private void priceFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_priceFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_priceFieldActionPerformed

private void cbSuppliersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSuppliersActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cbSuppliersActionPerformed
Expand Down Expand Up @@ -608,7 +604,7 @@ public void run() {
private javax.swing.JPanel jPanel5;
private javax.swing.JScrollPane jScrollPane1;
public javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTextField priceField;
private javax.swing.JFormattedTextField priceField;
private javax.swing.JTextField productField;
private javax.swing.JTextField searchField;
private javax.swing.JTextField stock_qtyField;
Expand Down
18 changes: 0 additions & 18 deletions src/main/resources/config.properties

This file was deleted.

0 comments on commit ccec985

Please sign in to comment.