Aniadido soporte para cambiar de mes

This commit is contained in:
2019-11-14 21:58:58 +01:00
parent 21203e9524
commit 86c642dba9
6 changed files with 39 additions and 11 deletions

View File

@@ -50,16 +50,15 @@ public class Menu extends JFrame{
setLocationRelativeTo(null);
ControladorPanelLateral controlador3 = new ControladorPanelLateral(this.panel, this);
this.pestania.addChangeListener((ChangeListener)->{
if(this.pestania.getSelectedIndex() == 0) {
this.panel.actualizarDatos(meses.getGestionesActuales().get(0));
}else {
this.panel.actualizarDatos(meses.getGestionesActuales().get(1));
if(this.pestania.getTabCount()<0) {
this.panel.actualizarDatos(meses.getGestionesActuales().get(this.pestania.getSelectedIndex()));
}
});
this.add(this.panel);
}
private void iniciarMes(int anio, Month mes) {
this.pestania.removeAll();
meses.aniadirGestion("Ingresos", anio, mes, true);
meses.aniadirGestion("Gastos", anio, mes, false);
this.pestanias=new ArrayList<VistaAniadirVisualizar>();
@@ -68,28 +67,34 @@ public class Menu extends JFrame{
this.controladores=new ArrayList<ControladorAniadirVisualizar>();
this.controladores.add(new ControladorAniadirVisualizar(this.pestanias.get(0)));
this.controladores.add(new ControladorAniadirVisualizar(this.pestanias.get(1)));
this.cargarPestanias();
}
private void cargarGestiones(int anio, Month mes) {
void cargarGestiones(int anio, Month mes) {
if(this.meses==null) {
this.meses=new Meses();
}
this.meses.elegirMes(anio, mes);
if(this.meses.getGestionesActuales().size() == 0) {
this.iniciarMes(anio, mes);
System.out.println("entra");
}else {
this.cargarMes();
}
}
private void cargarMes() {
this.pestanias=new ArrayList<VistaAniadirVisualizar>();
this.controladores=new ArrayList<ControladorAniadirVisualizar>();
this.pestania.removeAll();
this.pestanias.clear();
this.controladores.clear();
for(Gestion gestion:this.meses.getGestionesActuales()) {
VistaAniadirVisualizar vista = new VistaAniadirVisualizar(this, gestion);
this.pestania.add(vista);
this.controladores.add(new ControladorAniadirVisualizar(vista));
ControladorAniadirVisualizar controlador = new ControladorAniadirVisualizar(vista);
vista.iniciarGestion();
this.pestanias.add(vista);
this.controladores.add(controlador);
}
this.cargarPestanias();
}
void cargarPestanias() {