Mejoras de estilo y otros
This commit is contained in:
		
							parent
							
								
									0ade46bde2
								
							
						
					
					
						commit
						667182d76e
					
				
							
								
								
									
										1
									
								
								bin/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								bin/.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,2 +1,3 @@ | |||||||
| /VistaControlador/ | /VistaControlador/ | ||||||
| /Logica/ | /Logica/ | ||||||
|  | /IniciarSesion/ | ||||||
|  | |||||||
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										27
									
								
								src/IniciarSesion/Usuario.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/IniciarSesion/Usuario.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | package IniciarSesion; | ||||||
|  | 
 | ||||||
|  | import java.io.Serializable; | ||||||
|  | 
 | ||||||
|  | public class Usuario implements Serializable{ | ||||||
|  | 	String nombre; | ||||||
|  | 	String contrasenia; | ||||||
|  | 	boolean admin; | ||||||
|  | 	 | ||||||
|  | 	public Usuario(String nombre, String contrasenia, boolean admin) { | ||||||
|  | 		this.admin = admin; | ||||||
|  | 		this.nombre = nombre; | ||||||
|  | 		this.contrasenia = contrasenia; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public boolean comprobar(String contrasenia) { | ||||||
|  | 		if(this.contrasenia.equals(contrasenia)) { | ||||||
|  | 			return true; | ||||||
|  | 		} | ||||||
|  | 		return false; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public String getUsuario() { | ||||||
|  | 		return this.nombre; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
							
								
								
									
										8
									
								
								src/IniciarSesion/Validacion.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/IniciarSesion/Validacion.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | |||||||
|  | package IniciarSesion; | ||||||
|  | 
 | ||||||
|  | import java.io.File; | ||||||
|  | 
 | ||||||
|  | public class Validacion { | ||||||
|  | 	File fichero; | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -13,15 +13,15 @@ public class Gestion{ | |||||||
| 	 | 	 | ||||||
| 	public Gestion() { | 	public Gestion() { | ||||||
| 		this.gestiones=new Vector<Transaccion>(); | 		this.gestiones=new Vector<Transaccion>(); | ||||||
| 		this.suma=0; | 		this.suma = 0; | ||||||
| 		Gestion.total=0; | 		Gestion.total = 0; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public Gestion(String nombre) { | 	public Gestion(String nombre) { | ||||||
| 		this.gestiones=new Vector<Transaccion>(); | 		this.gestiones = new Vector<Transaccion>(); | ||||||
| 		this.suma=0; | 		this.suma = 0; | ||||||
| 		Gestion.total=0; | 		Gestion.total = 0; | ||||||
| 		this.nombre=nombre; | 		this.nombre = nombre; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public String getNombre() { | 	public String getNombre() { | ||||||
| @ -30,11 +30,11 @@ public class Gestion{ | |||||||
| 	 | 	 | ||||||
| 	public void aniadirGasto(Transaccion transaccion) { | 	public void aniadirGasto(Transaccion transaccion) { | ||||||
| 		this.gestiones.add(transaccion); | 		this.gestiones.add(transaccion); | ||||||
| 		this.suma+=transaccion.getDinero(); | 		this.suma += transaccion.getDinero(); | ||||||
| 		if(transaccion.isPositivo()) { | 		if(transaccion.isPositivo()) { | ||||||
| 			Gestion.total+=transaccion.getDinero(); | 			Gestion.total += transaccion.getDinero(); | ||||||
| 		}else { | 		}else { | ||||||
| 			Gestion.total-=transaccion.getDinero(); | 			Gestion.total -= transaccion.getDinero(); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -52,18 +52,18 @@ public class Gestion{ | |||||||
| 	 | 	 | ||||||
| 	public void alterarVisibilidad(int elemento) { | 	public void alterarVisibilidad(int elemento) { | ||||||
| 		if(this.gestiones.get(elemento).alterarVisivilidad()) { | 		if(this.gestiones.get(elemento).alterarVisivilidad()) { | ||||||
| 			this.suma+=this.gestiones.get(elemento).getDinero(); | 			this.suma += this.gestiones.get(elemento).getDinero(); | ||||||
| 			if(this.gestiones.get(elemento).isPositivo()) { | 			if(this.gestiones.get(elemento).isPositivo()) { | ||||||
| 				Gestion.total+=this.gestiones.get(elemento).getDinero(); | 				Gestion.total += this.gestiones.get(elemento).getDinero(); | ||||||
| 			}else { | 			}else { | ||||||
| 				Gestion.total-=this.gestiones.get(elemento).getDinero(); | 				Gestion.total -= this.gestiones.get(elemento).getDinero(); | ||||||
| 			} | 			} | ||||||
| 		}else { | 		}else { | ||||||
| 			this.suma-=this.gestiones.get(elemento).getDinero(); | 			this.suma -= this.gestiones.get(elemento).getDinero(); | ||||||
| 			if(this.gestiones.get(elemento).isPositivo()) { | 			if(this.gestiones.get(elemento).isPositivo()) { | ||||||
| 				Gestion.total-=this.gestiones.get(elemento).getDinero(); | 				Gestion.total -= this.gestiones.get(elemento).getDinero(); | ||||||
| 			}else { | 			}else { | ||||||
| 				Gestion.total+=this.gestiones.get(elemento).getDinero(); | 				Gestion.total += this.gestiones.get(elemento).getDinero(); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -8,13 +8,13 @@ private ArrayList<Mes> meses; | |||||||
| 	private int mesActual=0; | 	private int mesActual=0; | ||||||
| 	 | 	 | ||||||
| 	public Meses() { | 	public Meses() { | ||||||
| 		this.meses=new ArrayList<Mes>(); | 		this.meses = new ArrayList<Mes>(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public void aniadirTransaccion(Transaccion transaccion, String nombre) { | 	public void aniadirTransaccion(Transaccion transaccion, String nombre) { | ||||||
| 		for(Mes mes:this.meses) { | 		for(Mes mes:this.meses) { | ||||||
| 			if(transaccion.getDia().getMonth().equals(mes.getMes()) && | 			if(transaccion.getDia().getMonth().equals(mes.getMes()) && | ||||||
| 					transaccion.getDia().getYear()==mes.getAnio()){ | 					transaccion.getDia().getYear() == mes.getAnio()){ | ||||||
| 				mes.aniadirTransaccion(transaccion, nombre); | 				mes.aniadirTransaccion(transaccion, nombre); | ||||||
| 				return; | 				return; | ||||||
| 			} | 			} | ||||||
| @ -24,9 +24,9 @@ private ArrayList<Mes> meses; | |||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public void elegirMes(int anio, Month mes) { | 	public void elegirMes(int anio, Month mes) { | ||||||
| 		for(int i=0;i<this.meses.size();i++) { | 		for(int i = 0; i < this.meses.size(); i++) { | ||||||
| 			if(this.meses.get(i).getAnio()==anio && this.meses.get(i).getMes().equals(mes)) { | 			if(this.meses.get(i).getAnio()==anio && this.meses.get(i).getMes().equals(mes)) { | ||||||
| 				this.mesActual=0; | 				this.mesActual = 0; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -35,9 +35,6 @@ private ArrayList<Mes> meses; | |||||||
| 		return this.meses.get(this.mesActual).getGestiones(); | 		return this.meses.get(this.mesActual).getGestiones(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	 |  | ||||||
| 	 |  | ||||||
| 
 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| class Mes{ | class Mes{ | ||||||
| @ -46,7 +43,7 @@ class Mes{ | |||||||
| 	int total; | 	int total; | ||||||
| 	ArrayList<Gestion> gestiones; | 	ArrayList<Gestion> gestiones; | ||||||
| 	Mes(ArrayList<Gestion> gestiones){ | 	Mes(ArrayList<Gestion> gestiones){ | ||||||
| 		this.gestiones=gestiones; | 		this.gestiones = gestiones; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	void aniadirTransaccion(Transaccion transaccion, String nombre) { | 	void aniadirTransaccion(Transaccion transaccion, String nombre) { | ||||||
|  | |||||||
| @ -10,23 +10,23 @@ public class Transaccion { | |||||||
| 	private boolean positivo; | 	private boolean positivo; | ||||||
| 	 | 	 | ||||||
| 	public Transaccion(String nombre, float dinero){ | 	public Transaccion(String nombre, float dinero){ | ||||||
| 		this.nombre=nombre; | 		this.nombre = nombre; | ||||||
| 		this.dinero=dinero; | 		this.dinero = dinero; | ||||||
| 		this.visible=true; | 		this.visible = true; | ||||||
| 		this.dia=LocalDate.now(); | 		this.dia = LocalDate.now(); | ||||||
| 		this.positivo=true; | 		this.positivo = true; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public Transaccion(String nombre, float dinero, LocalDate dia, boolean positivo){ | 	public Transaccion(String nombre, float dinero, LocalDate dia, boolean positivo){ | ||||||
| 		this.nombre=nombre; | 		this.nombre = nombre; | ||||||
| 		this.dinero=dinero; | 		this.dinero = dinero; | ||||||
| 		this.visible=true; | 		this.visible = true; | ||||||
| 		this.positivo=positivo; | 		this.positivo = positivo; | ||||||
| 		this.dia=dia; | 		this.dia = dia; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public String toString() { | 	public String toString() { | ||||||
| 		return this.nombre+" "+this.dinero; | 		return this.nombre + " " + this.dinero; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public boolean getVisivilidad() { | 	public boolean getVisivilidad() { | ||||||
| @ -34,16 +34,11 @@ public class Transaccion { | |||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public boolean alterarVisivilidad() { | 	public boolean alterarVisivilidad() { | ||||||
| 		this.visible=!this.visible; | 		this.visible =! this.visible; | ||||||
| 		return this.visible; | 		return this.visible; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public float getDinero() { | 	public float getDinero() { | ||||||
| 		/*if(positivo) { |  | ||||||
| 			return this.dinero; |  | ||||||
| 		}else { |  | ||||||
| 			return -this.dinero; |  | ||||||
| 		}*/ |  | ||||||
| 		return this.dinero; | 		return this.dinero; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | |||||||
| @ -12,7 +12,7 @@ class CheckBoxList<E> extends JCheckBox implements ListCellRenderer<E> { | |||||||
| 	private static final long serialVersionUID = 3734536442230283966L; | 	private static final long serialVersionUID = 3734536442230283966L; | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public Component getListCellRendererComponent(JList<? extends E> list,E value, int index, boolean isSelected, boolean cellHasFocus) { | 	public Component getListCellRendererComponent(JList<? extends E> list, E value, int index, boolean isSelected, boolean cellHasFocus) { | ||||||
| 		setComponentOrientation(list.getComponentOrientation()); | 		setComponentOrientation(list.getComponentOrientation()); | ||||||
| 
 | 
 | ||||||
| 		setFont(list.getFont()); | 		setFont(list.getFont()); | ||||||
|  | |||||||
| @ -13,20 +13,20 @@ public class ControladorAniadirVisualizar implements ActionListener,ChangeListen | |||||||
| 
 | 
 | ||||||
| 	private VistaAniadirVisualizar vista; | 	private VistaAniadirVisualizar vista; | ||||||
| 	public ControladorAniadirVisualizar(VistaAniadirVisualizar vista) { | 	public ControladorAniadirVisualizar(VistaAniadirVisualizar vista) { | ||||||
| 		this.vista=vista; | 		this.vista = vista; | ||||||
| 		this.aniadirListeners(); | 		this.aniadirListeners(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public void actionPerformed(ActionEvent e) { | 	public void actionPerformed(ActionEvent e) { | ||||||
| 		if(e.getActionCommand().equals(this.vista.boton.getActionCommand())) { | 		if(e.getActionCommand().equals(this.vista.boton.getActionCommand())) { | ||||||
| 			String nombre=JOptionPane.showInputDialog("Introduce un nuevo gasto o ingreso"); | 			String nombre=JOptionPane.showInputDialog("Introduce un nuevo gasto o ingreso"); | ||||||
| 			if(nombre==null) return; | 			if(nombre == null) return; | ||||||
| 			if(nombre.equals("")) { | 			if(nombre.equals("")) { | ||||||
| 				JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE); | 				JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE); | ||||||
| 				return; | 				return; | ||||||
| 			} | 			} | ||||||
| 			String dinero=JOptionPane.showInputDialog("Introduce a cuanto asciende"); | 			String dinero = JOptionPane.showInputDialog("Introduce a cuanto asciende"); | ||||||
| 			if(dinero==null) return; | 			if(dinero == null) return; | ||||||
| 			if(dinero.equals("")) { | 			if(dinero.equals("")) { | ||||||
| 				JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE); | 				JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE); | ||||||
| 				return; | 				return; | ||||||
| @ -41,8 +41,8 @@ public class ControladorAniadirVisualizar implements ActionListener,ChangeListen | |||||||
| 				JOptionPane.showMessageDialog(null, "Debe introducir un numero", "error", JOptionPane.WARNING_MESSAGE); | 				JOptionPane.showMessageDialog(null, "Debe introducir un numero", "error", JOptionPane.WARNING_MESSAGE); | ||||||
| 			} | 			} | ||||||
| 		}else { | 		}else { | ||||||
| 			JCheckBox pulsado=(JCheckBox)e.getSource(); | 			JCheckBox pulsado = (JCheckBox)e.getSource(); | ||||||
| 			for(int i=0;i<vista.gestiones.getElementos().size();i++) { | 			for(int i = 0; i < vista.gestiones.getElementos().size();i++) { | ||||||
| 				if(vista.gestiones.getElementos().get(i).toString().equals(pulsado.getText())) { | 				if(vista.gestiones.getElementos().get(i).toString().equals(pulsado.getText())) { | ||||||
| 					vista.gestiones.alterarVisibilidad(i); | 					vista.gestiones.alterarVisibilidad(i); | ||||||
| 					this.vista.menu.panel.actualizarDatos(this.vista.gestiones); | 					this.vista.menu.panel.actualizarDatos(this.vista.gestiones); | ||||||
| @ -56,7 +56,7 @@ public class ControladorAniadirVisualizar implements ActionListener,ChangeListen | |||||||
| 	private void aniadirListeners() { | 	private void aniadirListeners() { | ||||||
| 		vista.boton.addActionListener(this); | 		vista.boton.addActionListener(this); | ||||||
| 		vista.boton.setActionCommand("Aniadir"); | 		vista.boton.setActionCommand("Aniadir"); | ||||||
| 		int contador=0; | 		int contador = 0; | ||||||
| 		for(JCheckBox check:this.vista.transacciones) { | 		for(JCheckBox check:this.vista.transacciones) { | ||||||
| 			check.addActionListener(this); | 			check.addActionListener(this); | ||||||
| 			check.setActionCommand("pulsar "+contador); | 			check.setActionCommand("pulsar "+contador); | ||||||
|  | |||||||
| @ -26,33 +26,30 @@ public class ControladorPanelLateral implements ActionListener, DateChangeListen | |||||||
| 	 | 	 | ||||||
| 	 | 	 | ||||||
| 	public ControladorPanelLateral(VistaPanelLateral vista) { | 	public ControladorPanelLateral(VistaPanelLateral vista) { | ||||||
| 		this.vista=vista; | 		this.vista = vista; | ||||||
| 		this.aniadirElementos(); | 		this.aniadirElementos(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public void actionPerformed(ActionEvent e) { | 	public void actionPerformed(ActionEvent e) { | ||||||
| 		if(e.getActionCommand().equals(this.vista.mostrarEstadisticas.getActionCommand())) { | 		if(e.getActionCommand().equals(this.vista.mostrarEstadisticas.getActionCommand())) { | ||||||
| 			 | 			 | ||||||
| 			XYSeries serie=new XYSeries("Mes"); | 			XYSeries serie = new XYSeries("Mes"); | ||||||
| 			serie.add(10,1); | 			serie.add(10,1); | ||||||
| 			serie.add(4,2); | 			serie.add(4,2); | ||||||
| 			serie.add(90,10); | 			serie.add(90,10); | ||||||
| 			XYSeriesCollection dataset=new XYSeriesCollection(serie); | 			XYSeriesCollection dataset = new XYSeriesCollection(serie); | ||||||
| 			JFreeChart chart=ChartFactory.createXYLineChart("Mes", "Dias", "Gastos", dataset); | 			JFreeChart chart = ChartFactory.createXYLineChart("Mes", "Dias", "Gastos", dataset); | ||||||
| 			ChartFrame frame=new ChartFrame("Estadisricas", chart); | 			ChartFrame frame = new ChartFrame("Estadisricas", chart); | ||||||
| 			frame.setVisible(true); | 			frame.setVisible(true); | ||||||
| 			frame.setSize(700,500); | 			frame.setSize(700,500); | ||||||
| 		} | 		} | ||||||
| 		//}else if(e.getActionCommand().equals(this.vista.elegirMes.getActionCommand())){ |  | ||||||
| 			 |  | ||||||
| 		//} |  | ||||||
| 		 | 		 | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	private void aniadirElementos() { | 	private void aniadirElementos() { | ||||||
| 		this.vista.mostrarEstadisticas.addActionListener(this); | 		this.vista.mostrarEstadisticas.addActionListener(this); | ||||||
| 		this.vista.mostrarEstadisticas.setActionCommand("Mostrar estadisticas"); | 		this.vista.mostrarEstadisticas.setActionCommand("Mostrar estadisticas"); | ||||||
| 		if(VistaPanelLateral.elegirMes.getDateChangeListeners().size()==0) { | 		if(VistaPanelLateral.elegirMes.getDateChangeListeners().size() == 0) { | ||||||
| 			VistaPanelLateral.elegirMes.addDateChangeListener(this); | 			VistaPanelLateral.elegirMes.addDateChangeListener(this); | ||||||
| 			this.mes=VistaPanelLateral.elegirMes.getDate().getMonth(); | 			this.mes=VistaPanelLateral.elegirMes.getDate().getMonth(); | ||||||
| 			this.anio=VistaPanelLateral.elegirMes.getDate().getYear(); | 			this.anio=VistaPanelLateral.elegirMes.getDate().getYear(); | ||||||
|  | |||||||
| @ -24,19 +24,19 @@ public class Menu extends JFrame{ | |||||||
| 	protected Gestion datosIngresos; | 	protected Gestion datosIngresos; | ||||||
| 	public Menu() { | 	public Menu() { | ||||||
| 		VistaAniadirVisualizar.setPanelLateral(panel); | 		VistaAniadirVisualizar.setPanelLateral(panel); | ||||||
| 		this.datosGastos=new Gestion(); | 		this.datosGastos = new Gestion(); | ||||||
| 		this.datosIngresos=new Gestion(); | 		this.datosIngresos = new Gestion(); | ||||||
| 		this.setLayout(new GridBagLayout()); | 		this.setLayout(new GridBagLayout()); | ||||||
| 		GridBagConstraints constrain=new GridBagConstraints(); | 		GridBagConstraints constrain = new GridBagConstraints(); | ||||||
| 		this.panel=new VistaPanelLateral(constrain); | 		this.panel = new VistaPanelLateral(constrain); | ||||||
| 		this.ingresos=new VistaAniadirVisualizar(this,datosIngresos,true); | 		this.ingresos = new VistaAniadirVisualizar(this,datosIngresos,true); | ||||||
| 		this.gastos=new VistaAniadirVisualizar(this,datosGastos,false); | 		this.gastos = new VistaAniadirVisualizar(this,datosGastos,false); | ||||||
| 		this.panelCentral=new JPanel(); | 		this.panelCentral = new JPanel(); | ||||||
| 		this.pestania=new JTabbedPane(); | 		this.pestania = new JTabbedPane(); | ||||||
| 		constrain.fill=GridBagConstraints.VERTICAL; | 		constrain.fill = GridBagConstraints.VERTICAL; | ||||||
| 		constrain.gridx=0; | 		constrain.gridx = 0; | ||||||
| 		constrain.gridy=0; | 		constrain.gridy = 0; | ||||||
| 		constrain.weightx=2; | 		constrain.weightx = 2; | ||||||
| 		this.panelCentral.add(pestania,constrain); | 		this.panelCentral.add(pestania,constrain); | ||||||
| 		this.pestania.addTab("Ingresos", ingresos); | 		this.pestania.addTab("Ingresos", ingresos); | ||||||
| 		this.pestania.addTab("Gastos", gastos); | 		this.pestania.addTab("Gastos", gastos); | ||||||
| @ -45,17 +45,12 @@ public class Menu extends JFrame{ | |||||||
| 		setSize(new Dimension(420,320)); | 		setSize(new Dimension(420,320)); | ||||||
| 		setDefaultCloseOperation(3); | 		setDefaultCloseOperation(3); | ||||||
| 		setLocationRelativeTo(null); | 		setLocationRelativeTo(null); | ||||||
| 		ControladorAniadirVisualizar controlador=new ControladorAniadirVisualizar(this.ingresos); | 		ControladorAniadirVisualizar controlador = new ControladorAniadirVisualizar(this.ingresos); | ||||||
| 		ControladorAniadirVisualizar controlador2=new ControladorAniadirVisualizar(this.gastos); | 		ControladorAniadirVisualizar controlador2 = new ControladorAniadirVisualizar(this.gastos); | ||||||
| 		ControladorPanelLateral controlador3=new ControladorPanelLateral(this.panel); | 		ControladorPanelLateral controlador3 = new ControladorPanelLateral(this.panel); | ||||||
| 		/*constrain.fill=GridBagConstraints.HORIZONTAL; |  | ||||||
| 		constrain.gridx=1; |  | ||||||
| 		constrain.gridy=0; |  | ||||||
| 		constrain.weightx=1; |  | ||||||
| 		constrain.weighty=2;*/ |  | ||||||
| 		this.panel.actualizarDatos(datosIngresos); | 		this.panel.actualizarDatos(datosIngresos); | ||||||
| 		this.pestania.addChangeListener((ChangeListener)->{ | 		this.pestania.addChangeListener((ChangeListener)->{ | ||||||
| 			if(this.pestania.getSelectedIndex()==0) { | 			if(this.pestania.getSelectedIndex() == 0) { | ||||||
| 				this.panel.actualizarDatos(datosIngresos); | 				this.panel.actualizarDatos(datosIngresos); | ||||||
| 			}else { | 			}else { | ||||||
| 				this.panel.actualizarDatos(datosGastos); | 				this.panel.actualizarDatos(datosGastos); | ||||||
| @ -64,6 +59,4 @@ public class Menu extends JFrame{ | |||||||
| 		this.add(this.panel); | 		this.add(this.panel); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	 |  | ||||||
| 	 |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -23,16 +23,15 @@ public class VistaAniadirVisualizar extends JPanel{ | |||||||
| 	boolean positivo; | 	boolean positivo; | ||||||
| 	static VistaPanelLateral panelLateral; | 	static VistaPanelLateral panelLateral; | ||||||
| 	public VistaAniadirVisualizar(Menu menu, Gestion gestion,boolean positivo) { | 	public VistaAniadirVisualizar(Menu menu, Gestion gestion,boolean positivo) { | ||||||
| 		this.positivo=positivo; | 		this.positivo = positivo; | ||||||
| 		this.gestiones=gestion; | 		this.gestiones = gestion; | ||||||
| 		this.transacciones=new LinkedList<JCheckBox>(); | 		this.transacciones = new LinkedList<JCheckBox>(); | ||||||
| 		this.menu=menu; | 		this.menu = menu; | ||||||
| 		this.x=100; | 		this.x = 100; | ||||||
| 		this.boton=new JButton("aniadir"); | 		this.boton = new JButton("aniadir"); | ||||||
| 		//this.gestiones=new Gestion(); |  | ||||||
| 		this.add(boton); | 		this.add(boton); | ||||||
| 		this.cuadro=new JPanel(); | 		this.cuadro = new JPanel(); | ||||||
| 		this.panel=new JScrollPane(cuadro); | 		this.panel = new JScrollPane(cuadro); | ||||||
| 		this.panel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); | 		this.panel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); | ||||||
| 		this.panel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); | 		this.panel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); | ||||||
| 		cuadro.setPreferredSize(new Dimension(x, y)); | 		cuadro.setPreferredSize(new Dimension(x, y)); | ||||||
| @ -42,19 +41,19 @@ public class VistaAniadirVisualizar extends JPanel{ | |||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static void setPanelLateral(VistaPanelLateral panel) { | 	public static void setPanelLateral(VistaPanelLateral panel) { | ||||||
| 		VistaAniadirVisualizar.panelLateral=panel; | 		VistaAniadirVisualizar.panelLateral = panel; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public void aniadirElemento(String nombre, float dinero, ControladorAniadirVisualizar controlador) { | 	public void aniadirElemento(String nombre, float dinero, ControladorAniadirVisualizar controlador) { | ||||||
| 		Transaccion transaccion=new Transaccion(nombre, dinero,panelLateral.getDate(),this.positivo); | 		Transaccion transaccion = new Transaccion(nombre, dinero,panelLateral.getDate(),this.positivo); | ||||||
| 		this.gestiones.aniadirGasto(transaccion); | 		this.gestiones.aniadirGasto(transaccion); | ||||||
| 		JCheckBox check=new JCheckBox(transaccion.toString()); | 		JCheckBox check = new JCheckBox(transaccion.toString()); | ||||||
| 		check.setSelected(true); | 		check.setSelected(true); | ||||||
| 		check.setSize(new Dimension(x,VistaAniadirVisualizar.altoCheck)); | 		check.setSize(new Dimension(x,VistaAniadirVisualizar.altoCheck)); | ||||||
| 		check.addActionListener(controlador); | 		check.addActionListener(controlador); | ||||||
| 		this.transacciones.add(check); | 		this.transacciones.add(check); | ||||||
| 		this.cuadro.add(check); | 		this.cuadro.add(check); | ||||||
| 		this.y+=VistaAniadirVisualizar.altoCheck; | 		this.y += VistaAniadirVisualizar.altoCheck; | ||||||
| 		cuadro.setPreferredSize(new Dimension(x, y)); | 		cuadro.setPreferredSize(new Dimension(x, y)); | ||||||
| 		this.revalidate(); | 		this.revalidate(); | ||||||
| 		this.repaint(); | 		this.repaint(); | ||||||
|  | |||||||
| @ -17,32 +17,32 @@ public class VistaPanelLateral extends JPanel{ | |||||||
| 	protected JTextArea total; | 	protected JTextArea total; | ||||||
| 	protected JTextArea gastoEnvio; | 	protected JTextArea gastoEnvio; | ||||||
| 	//protected JButton elegirMes; | 	//protected JButton elegirMes; | ||||||
| 	protected static DatePicker elegirMes=inicializarCalendario(); | 	protected static DatePicker elegirMes = inicializarCalendario(); | ||||||
| 	protected JButton mostrarEstadisticas; | 	protected JButton mostrarEstadisticas; | ||||||
| 	 | 	 | ||||||
| 	VistaPanelLateral(GridBagConstraints constrain){ | 	VistaPanelLateral(GridBagConstraints constrain){ | ||||||
| 		this.setPreferredSize(new Dimension(200,200)); | 		this.setPreferredSize(new Dimension(200,200)); | ||||||
| 		this.total=new JTextArea(); | 		this.total = new JTextArea(); | ||||||
| 		this.gastoEnvio=new JTextArea(); | 		this.gastoEnvio = new JTextArea(); | ||||||
| 		this.mostrarEstadisticas=new JButton("Mostrar grafico del mes"); | 		this.mostrarEstadisticas = new JButton("Mostrar grafico del mes"); | ||||||
| 		this.add(this.mostrarEstadisticas); | 		this.add(this.mostrarEstadisticas); | ||||||
| 		constrain.gridx=1; | 		constrain.gridx = 1; | ||||||
| 		constrain.gridy=0; | 		constrain.gridy = 0; | ||||||
| 		constrain.weightx=2; | 		constrain.weightx = 2; | ||||||
| 		this.add(VistaPanelLateral.elegirMes); | 		this.add(VistaPanelLateral.elegirMes); | ||||||
| 		constrain.gridx=1; | 		constrain.gridx = 1; | ||||||
| 		constrain.gridy=1; | 		constrain.gridy = 1; | ||||||
| 		constrain.weightx=2; | 		constrain.weightx = 2; | ||||||
| 		this.add(this.total); | 		this.add(this.total); | ||||||
| 		constrain.gridx=1; | 		constrain.gridx = 1; | ||||||
| 		constrain.gridy=2; | 		constrain.gridy = 2; | ||||||
| 		constrain.weightx=2; | 		constrain.weightx = 2; | ||||||
| 		this.add(this.gastoEnvio); | 		this.add(this.gastoEnvio); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	void actualizarDatos(Gestion gestion) { | 	void actualizarDatos(Gestion gestion) { | ||||||
| 		this.total.setText("Total: "+String.valueOf(Gestion.getTotal())+"€"); | 		this.total.setText("Total: " + String.valueOf(Gestion.getTotal()) + "€"); | ||||||
| 		this.gastoEnvio.setText("Suma: "+String.valueOf(gestion.getSuma())+"€"); | 		this.gastoEnvio.setText("Suma: " + String.valueOf(gestion.getSuma()) + "€"); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	static LocalDate getDate() { | 	static LocalDate getDate() { | ||||||
| @ -50,7 +50,7 @@ public class VistaPanelLateral extends JPanel{ | |||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	static DatePicker inicializarCalendario() { | 	static DatePicker inicializarCalendario() { | ||||||
| 		DatePicker ret=new DatePicker(); | 		DatePicker ret = new DatePicker(); | ||||||
| 		ret.setDate(LocalDate.now()); | 		ret.setDate(LocalDate.now()); | ||||||
| 		return ret; | 		return ret; | ||||||
| 	} | 	} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user