From d66fd9c45b8ccf0d94bd3e4f0a276a0ca8988ea0 Mon Sep 17 00:00:00 2001 From: francescods Date: Tue, 5 Nov 2024 09:01:42 +0100 Subject: [PATCH] modifica funzione caricaPannello rimosso JPanel --- src/puntocassa/PuntoCassa.java | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/puntocassa/PuntoCassa.java b/src/puntocassa/PuntoCassa.java index de5fd34..e12fca7 100644 --- a/src/puntocassa/PuntoCassa.java +++ b/src/puntocassa/PuntoCassa.java @@ -2210,10 +2210,10 @@ public class PuntoCassa extends JFrame implements ActionListener { menuGiornoPresente = true; sql = sql + sql2; } - JPanel pnl = this.pnlProdotti; + //JPanel pnl = this.pnlProdotti; + var listaBottoni = new ArrayList(); - pnl.setLayout(new GridLayout(6, 5, 1, 1)); - pnl.removeAll(); + for (Integer r = 0; r < 6; r++) { Color c2 = new Color(255, 153, 255); switch (r) { @@ -2269,7 +2269,8 @@ public class PuntoCassa extends JFrame implements ActionListener { bt.addActionListener(this); bt.setVisible(true); - pnl.add(bt); + //this.pnlProdotti.add(bt); + listaBottoni.add(bt); np++; if (np == 5) { break; @@ -2298,7 +2299,8 @@ public class PuntoCassa extends JFrame implements ActionListener { bt.setVerticalTextPosition(SwingConstants.TOP); bt.addActionListener(this); bt.setVisible(true); - pnl.add(bt); + //this.pnlProdotti.add(bt); + listaBottoni.add(bt); } rs.close(); st.close(); @@ -2309,9 +2311,16 @@ public class PuntoCassa extends JFrame implements ActionListener { } } - - this.revalidate(); - this.repaint(); + this.pnlProdotti.setLayout(new GridLayout(6, 5, 1, 1)); + this.pnlProdotti.removeAll(); + for(JToggleButton bt : listaBottoni){ + this.pnlProdotti.add(bt); + } + + this.pnlProdotti.revalidate(); + this.pnlProdotti.repaint(); + //this.revalidate(); + //this.repaint(); }