diff --git a/src/guivendite/GUIVendite.form b/src/guivendite/GUIVendite.form
index 056840d..ad97162 100644
--- a/src/guivendite/GUIVendite.form
+++ b/src/guivendite/GUIVendite.form
@@ -101,14 +101,10 @@
-
-
-
-
@@ -128,16 +124,25 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/guivendite/GUIVendite.java b/src/guivendite/GUIVendite.java
index 2fd8bf3..f569e6b 100644
--- a/src/guivendite/GUIVendite.java
+++ b/src/guivendite/GUIVendite.java
@@ -51,13 +51,6 @@ public class GUIVendite extends javax.swing.JFrame {
lblImportoTotale.setText("Importo totale");
- txtPrezzo.addFocusListener(new java.awt.event.FocusAdapter() {
- public void focusGained(java.awt.event.FocusEvent evt) {
- txtPrezzoFocusGained(evt);
- }
- });
-
-
txtQuantita.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
txtQuantitaFocusGained(evt);
@@ -70,10 +63,13 @@ public class GUIVendite extends javax.swing.JFrame {
btnAggiungi.addActionListener(this::btnAggiungiActionPerformed);
btnPrezzo.setText("Media prezzo");
+ btnPrezzo.addActionListener(this::btnPrezzoActionPerformed);
btnQuantita.setText("Media quantità ");
+ btnQuantita.addActionListener(this::btnQuantitaActionPerformed);
btnImportoTotale.setText("Tot. vendite");
+ btnImportoTotale.addActionListener(this::btnImportoTotaleActionPerformed);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@@ -148,6 +144,33 @@ public class GUIVendite extends javax.swing.JFrame {
txtQuantita.setBackground(Color.white);
}//GEN-LAST:event_txtQuantitaFocusGained
+ private void btnPrezzoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrezzoActionPerformed
+ double totale = 0;
+ for(Prodotto prodotto: prodotti){
+ totale += prodotto.getPrezzo();
+ }
+
+ txtPrezzo.setText(Double.toString(totale/prodotti.size()));
+ }//GEN-LAST:event_btnPrezzoActionPerformed
+
+ private void btnQuantitaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuantitaActionPerformed
+ double totale = 0;
+ for(Prodotto prodotto: prodotti){
+ totale += prodotto.getQuantita();
+ }
+
+ txtQuantita.setText(Double.toString(totale/prodotti.size()));
+ }//GEN-LAST:event_btnQuantitaActionPerformed
+
+ private void btnImportoTotaleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportoTotaleActionPerformed
+ double totale = 0;
+ for(Prodotto prodotto: prodotti){
+ totale += prodotto.getTotale();
+ }
+
+ txtImportoTotale.setText(Double.toString(totale));
+ }//GEN-LAST:event_btnImportoTotaleActionPerformed
+
private double leggiCampo(javax.swing.JTextField campo){
double valoreCampo = -1;