diff --git a/src/VistaControlador/BarraOpciones.java b/src/VistaControlador/BarraOpciones.java index 65de52b..ed0e213 100644 --- a/src/VistaControlador/BarraOpciones.java +++ b/src/VistaControlador/BarraOpciones.java @@ -21,6 +21,7 @@ public class BarraOpciones extends JMenuBar{ JMenu vistas; JMenuItem gestion; JMenuItem modificacion; + JMenuItem menuInterfaz; JMenu administracion; JMenuItem aniadirUsuario; @@ -56,6 +57,8 @@ public class BarraOpciones extends JMenuBar{ this.vistas.add(this.gestion); this.modificacion = new JMenuItem("Modificacion"); this.vistas.add(this.modificacion); + this.menuInterfaz = new JMenuItem("Gestion tema"); + this.vistas.add(this.menuInterfaz); this.administracion = new JMenu("Administracion"); this.add(this.administracion); this.aniadirUsuario = new JMenuItem("Aniadir usuario"); diff --git a/src/VistaControlador/ControladorBarra.java b/src/VistaControlador/ControladorBarra.java index ac977b5..5f7e9af 100644 --- a/src/VistaControlador/ControladorBarra.java +++ b/src/VistaControlador/ControladorBarra.java @@ -90,6 +90,10 @@ public class ControladorBarra implements ActionListener{ this.menu.cambiarVista(this.menu.VISTA_MODIFICAR); break; } + case "Ajustar tema":{ + this.menu.cambiarVista(this.menu.VISTA_INTERFAZ); + break; + } case "Aniadir usuario":{ Vista loggin = new Vista(Vista.Guardar); break; @@ -123,6 +127,8 @@ public class ControladorBarra implements ActionListener{ this.barra.gestion.setActionCommand("Cambiar Gestion"); this.barra.modificacion.addActionListener(this); this.barra.modificacion.setActionCommand("Cambiar Modificar"); + this.barra.menuInterfaz.addActionListener(this); + this.barra.menuInterfaz.setActionCommand("Ajustar tema"); this.barra.aniadirUsuario.addActionListener(this); this.barra.aniadirUsuario.setActionCommand("Aniadir usuario"); } diff --git a/src/VistaControlador/ControladorPanelInterfaz.java b/src/VistaControlador/ControladorPanelInterfaz.java index 047eb68..e07dcec 100644 --- a/src/VistaControlador/ControladorPanelInterfaz.java +++ b/src/VistaControlador/ControladorPanelInterfaz.java @@ -1,5 +1,6 @@ package VistaControlador; +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -13,11 +14,32 @@ public class ControladorPanelInterfaz implements ActionListener{ } private void aniadirListener() { - //this.vista. + this.vista.aplicarCambios.addActionListener(this); + this.vista.aplicarCambios.setActionCommand("Aplicar cambios"); } - @Override + + public void actionPerformed(ActionEvent arg0) { - // TODO Auto-generated method stub + switch(arg0.getActionCommand()) { + case "Aplicar cambios":{ + if(this.vista.aplicarBarra.isSelected()) { + if(this.vista.temaClaro.isSelected()) { + this.menu.barra.setBackground(Color.WHITE); + } else if(this.vista.temaOscuro.isSelected()) { + this.menu.barra.setBackground(Color.GRAY); + } else if(this.vista.temaRosa.isSelected()) { + this.menu.barra.setBackground(Color.PINK); + } + } + if(this.vista.temaClaro.isSelected()) { + this.menu.setTheme(0); + } else if(this.vista.temaOscuro.isSelected()) { + this.menu.setTheme(2); + } else if(this.vista.temaRosa.isSelected()) { + this.menu.setTheme(1); + } + } + } } } diff --git a/src/VistaControlador/Menu.java b/src/VistaControlador/Menu.java index 0e555bc..59647e1 100644 --- a/src/VistaControlador/Menu.java +++ b/src/VistaControlador/Menu.java @@ -31,6 +31,7 @@ import loggin.Vista; public class Menu extends JFrame{ static final int VISTA_MODIFICAR = 0; static final int VISTA_GESTION = 1; + static final int VISTA_INTERFAZ =2; JPanel panelCentral; JTabbedPane pestania; @@ -50,6 +51,7 @@ public class Menu extends JFrame{ DatePicker elegirMes; int anio; Month mes; + VistaPanelInterfaz panelInterfaz; /** * Constructor que carga los datos del menu @@ -81,6 +83,7 @@ public class Menu extends JFrame{ this.panelCentral.setLayout(new GridBagLayout()); this.panelGestion = new VistaPanelGestion(this.meses); this.panelModificar = new VistaPanelModificar(); + this.panelInterfaz = new VistaPanelInterfaz(); this.panel = this.panelGestion; constrain.fill = GridBagConstraints.HORIZONTAL; @@ -103,6 +106,7 @@ public class Menu extends JFrame{ setLocationRelativeTo(null); ControladorPanelGestion controlador3 = new ControladorPanelGestion(this.panelGestion, this); ControladorPanelModificar controlador4 = new ControladorPanelModificar(this.panelModificar, this); + ControladorPanelInterfaz controlador5 = new ControladorPanelInterfaz(this.panelInterfaz, this); this.listenerPestania(); this.elegirMes = new DatePicker(); @@ -370,6 +374,10 @@ public class Menu extends JFrame{ this.panel = this.panelModificar; break; } + case Menu.VISTA_INTERFAZ:{ + this.panel = this.panelInterfaz; + break; + } } this.panelCentral.add(this.panel,constrain); this.panel.repaint(); diff --git a/src/VistaControlador/VistaPanelInterfaz.java b/src/VistaControlador/VistaPanelInterfaz.java index 51db419..f96a33e 100644 --- a/src/VistaControlador/VistaPanelInterfaz.java +++ b/src/VistaControlador/VistaPanelInterfaz.java @@ -1,12 +1,16 @@ package VistaControlador; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; + +import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JRadioButton; import javax.swing.JRadioButtonMenuItem; public class VistaPanelInterfaz extends VistaPanel{ -JRadioButtonMenuItem menu; +ButtonGroup menu; JRadioButton temaClaro; JRadioButton temaRosa; JRadioButton temaOscuro; @@ -14,18 +18,34 @@ JCheckBox aplicarBarra; JButton aplicarCambios; VistaPanelInterfaz() { - this.menu = new JRadioButtonMenuItem(); - this.temaClaro = new JRadioButton(); + this.setLayout(new GridBagLayout()); + GridBagConstraints constrain = new GridBagConstraints(); + this.menu = new ButtonGroup(); + this.temaClaro = new JRadioButton("claro"); this.menu.add(this.temaClaro); - this.temaOscuro = new JRadioButton(); + this.temaOscuro = new JRadioButton("oscuro"); this.menu.add(this.temaOscuro); - this.temaRosa = new JRadioButton(); + this.temaRosa = new JRadioButton("rosa"); this.menu.add(this.temaRosa); - this.add(this.menu); - this.aplicarBarra = new JCheckBox(); - this.add(this.aplicarBarra); + //this.menu.setSize(200, 200); + constrain.gridx = 0; + constrain.gridy = 0; + this.add(this.temaClaro,constrain); + constrain.gridx = 1; + constrain.gridy = 0; + this.add(this.temaRosa,constrain); + constrain.gridx = 2; + constrain.gridy = 0; + this.add(this.temaOscuro,constrain); + this.aplicarBarra = new JCheckBox("Barra"); + constrain.gridx = 0; + constrain.gridy = 1; + this.add(this.aplicarBarra,constrain); this.aplicarCambios = new JButton("Aplicar"); - this.add(this.aplicarCambios); + constrain.gridx = 1; + constrain.gridy = 1; + this.add(this.aplicarCambios,constrain); + } }