diff --git a/.classpath b/.classpath index 51a8bba..79207fa 100644 --- a/.classpath +++ b/.classpath @@ -2,5 +2,7 @@ + + diff --git a/bin/.gitignore b/bin/.gitignore index f9897f2..a1bbed7 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1,3 +1 @@ /VistaControlador/ -/PedirDatos/ -/Logica/ diff --git a/bin/Logica/Gestion.class b/bin/Logica/Gestion.class new file mode 100644 index 0000000..b2e2050 Binary files /dev/null and b/bin/Logica/Gestion.class differ diff --git a/bin/Logica/Transaccion.class b/bin/Logica/Transaccion.class new file mode 100644 index 0000000..03febd1 Binary files /dev/null and b/bin/Logica/Transaccion.class differ diff --git a/src/VistaControlador/Controlador.java b/src/VistaControlador/ControladorAniadirVisualizar.java similarity index 79% rename from src/VistaControlador/Controlador.java rename to src/VistaControlador/ControladorAniadirVisualizar.java index 8f6e289..42c3afb 100644 --- a/src/VistaControlador/Controlador.java +++ b/src/VistaControlador/ControladorAniadirVisualizar.java @@ -9,10 +9,10 @@ import javax.swing.event.ChangeListener; import Logica.Gestion; -public class Controlador implements ActionListener,ChangeListener{ +public class ControladorAniadirVisualizar implements ActionListener,ChangeListener{ - private Vista vista; - public Controlador(Vista vista) { + private VistaAniadirVisualizar vista; + public ControladorAniadirVisualizar(VistaAniadirVisualizar vista) { this.vista=vista; this.aniadirListeners(); } @@ -34,9 +34,9 @@ public class Controlador implements ActionListener,ChangeListener{ try { this.vista.aniadirElemento(nombre, Integer.parseInt(dinero),this); - this.vista.menu.total.setText(String.valueOf(Gestion.getTotal())); - this.vista.menu.total.revalidate(); - this.vista.menu.total.repaint(); + this.vista.menu.panel.actualizarDatos(this.vista.gestiones); + this.vista.menu.panel.revalidate(); + this.vista.menu.panel.repaint(); }catch (NumberFormatException ex) { JOptionPane.showMessageDialog(null, "Debe introducir un numero", "error", JOptionPane.WARNING_MESSAGE); } @@ -45,9 +45,9 @@ public class Controlador implements ActionListener,ChangeListener{ for(int i=0;i{ + if(this.pestania.getSelectedIndex()==0) { + this.panel.actualizarDatos(datosIngresos); + }else { + this.panel.actualizarDatos(datosGastos); + } + }); + this.add(this.panel); } + + } diff --git a/src/VistaControlador/Vista.java b/src/VistaControlador/VistaAniadirVisualizar.java similarity index 79% rename from src/VistaControlador/Vista.java rename to src/VistaControlador/VistaAniadirVisualizar.java index fc2fcb2..b3b54c3 100644 --- a/src/VistaControlador/Vista.java +++ b/src/VistaControlador/VistaAniadirVisualizar.java @@ -11,21 +11,23 @@ import javax.swing.JScrollPane; import Logica.*; -public class Vista extends JPanel{ +public class VistaAniadirVisualizar extends JPanel{ private int x,y; - private static final int altocheck=28; + private static final int altoCheck=28; protected Gestion gestiones; protected JButton boton; protected LinkedList transacciones; JPanel cuadro; JScrollPane panel; Menu menu; - public Vista(Menu menu) { + + public VistaAniadirVisualizar(Menu menu, Gestion gestion) { + this.gestiones=gestion; this.transacciones=new LinkedList(); this.menu=menu; this.x=100; this.boton=new JButton("aniadir"); - this.gestiones=new Gestion(); + //this.gestiones=new Gestion(); this.add(boton); this.cuadro=new JPanel(); this.panel=new JScrollPane(cuadro); @@ -37,16 +39,16 @@ public class Vista extends JPanel{ this.add(panel); } - public void aniadirElemento(String nombre, int dinero, Controlador controlador) { + 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,Vista.altocheck)); + check.setSize(new Dimension(x,VistaAniadirVisualizar.altoCheck)); check.addActionListener(controlador); this.transacciones.add(check); this.cuadro.add(check); - this.y+=Vista.altocheck; + this.y+=VistaAniadirVisualizar.altoCheck; cuadro.setPreferredSize(new Dimension(x, y)); this.revalidate(); this.repaint(); diff --git a/src/VistaControlador/VistaPanelLateral.java b/src/VistaControlador/VistaPanelLateral.java new file mode 100644 index 0000000..da35911 --- /dev/null +++ b/src/VistaControlador/VistaPanelLateral.java @@ -0,0 +1,42 @@ +package VistaControlador; + +import java.awt.GridBagConstraints; + +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JTextArea; + +import Logica.Gestion; + +public class VistaPanelLateral extends JPanel{ + protected JTextArea total; + protected JTextArea gastoEnvio; + protected JButton elegirMes; + protected JButton mostrarEstadisticas; + + VistaPanelLateral(GridBagConstraints constrain){ + this.total=new JTextArea(); + this.gastoEnvio=new JTextArea(); + this.elegirMes=new JButton("Elegir mes"); + this.mostrarEstadisticas=new JButton("Mostrar grafico del mes"); + this.add(this.mostrarEstadisticas); + constrain.gridx=1; + constrain.gridy=0; + constrain.weightx=2; + this.add(this.elegirMes); + constrain.gridx=1; + constrain.gridy=1; + constrain.weightx=2; + this.add(this.total); + constrain.gridx=1; + constrain.gridy=2; + constrain.weightx=2; + this.add(this.gastoEnvio); + } + + void actualizarDatos(Gestion gestion) { + this.total.setText("Total: "+String.valueOf(Gestion.getTotal())+"€"); + this.gastoEnvio.setText("Suma: "+String.valueOf(gestion.getSuma())+"€"); + } + +}