Iniciando funcionalidad estadisticas

This commit is contained in:
roche
2019-11-12 13:58:07 +01:00
parent da28be150a
commit 8af689363a
9 changed files with 118 additions and 30 deletions

View File

@@ -0,0 +1,56 @@
package VistaControlador;
import java.awt.Dimension;
import java.util.LinkedList;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import Logica.*;
public class VistaAniadirVisualizar extends JPanel{
private int x,y;
private static final int altoCheck=28;
protected Gestion gestiones;
protected JButton boton;
protected LinkedList<JCheckBox> transacciones;
JPanel cuadro;
JScrollPane panel;
Menu menu;
public VistaAniadirVisualizar(Menu menu, Gestion gestion) {
this.gestiones=gestion;
this.transacciones=new LinkedList<JCheckBox>();
this.menu=menu;
this.x=100;
this.boton=new JButton("aniadir");
//this.gestiones=new Gestion();
this.add(boton);
this.cuadro=new JPanel();
this.panel=new JScrollPane(cuadro);
this.panel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
this.panel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
cuadro.setPreferredSize(new Dimension(x, y));
panel.setPreferredSize(new Dimension(100,200));
panel.setVisible(true);
this.add(panel);
}
public void aniadirElemento(String nombre, int dinero, ControladorAniadirVisualizar controlador) {
Transaccion transaccion=new Transaccion(nombre, dinero);
this.gestiones.aniadirGasto(transaccion);
JCheckBox check=new JCheckBox(transaccion.toString());
check.setSelected(true);
check.setSize(new Dimension(x,VistaAniadirVisualizar.altoCheck));
check.addActionListener(controlador);
this.transacciones.add(check);
this.cuadro.add(check);
this.y+=VistaAniadirVisualizar.altoCheck;
cuadro.setPreferredSize(new Dimension(x, y));
this.revalidate();
this.repaint();
}
}