Mejorando temas

This commit is contained in:
roche 2019-11-22 15:33:51 +01:00
parent fa437983d4
commit 9b9d1bb7bb
5 changed files with 71 additions and 12 deletions

View File

@ -21,6 +21,7 @@ public class BarraOpciones extends JMenuBar{
JMenu vistas; JMenu vistas;
JMenuItem gestion; JMenuItem gestion;
JMenuItem modificacion; JMenuItem modificacion;
JMenuItem menuInterfaz;
JMenu administracion; JMenu administracion;
JMenuItem aniadirUsuario; JMenuItem aniadirUsuario;
@ -56,6 +57,8 @@ public class BarraOpciones extends JMenuBar{
this.vistas.add(this.gestion); this.vistas.add(this.gestion);
this.modificacion = new JMenuItem("Modificacion"); this.modificacion = new JMenuItem("Modificacion");
this.vistas.add(this.modificacion); this.vistas.add(this.modificacion);
this.menuInterfaz = new JMenuItem("Gestion tema");
this.vistas.add(this.menuInterfaz);
this.administracion = new JMenu("Administracion"); this.administracion = new JMenu("Administracion");
this.add(this.administracion); this.add(this.administracion);
this.aniadirUsuario = new JMenuItem("Aniadir usuario"); this.aniadirUsuario = new JMenuItem("Aniadir usuario");

View File

@ -90,6 +90,10 @@ public class ControladorBarra implements ActionListener{
this.menu.cambiarVista(this.menu.VISTA_MODIFICAR); this.menu.cambiarVista(this.menu.VISTA_MODIFICAR);
break; break;
} }
case "Ajustar tema":{
this.menu.cambiarVista(this.menu.VISTA_INTERFAZ);
break;
}
case "Aniadir usuario":{ case "Aniadir usuario":{
Vista loggin = new Vista(Vista.Guardar); Vista loggin = new Vista(Vista.Guardar);
break; break;
@ -123,6 +127,8 @@ public class ControladorBarra implements ActionListener{
this.barra.gestion.setActionCommand("Cambiar Gestion"); this.barra.gestion.setActionCommand("Cambiar Gestion");
this.barra.modificacion.addActionListener(this); this.barra.modificacion.addActionListener(this);
this.barra.modificacion.setActionCommand("Cambiar Modificar"); 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.addActionListener(this);
this.barra.aniadirUsuario.setActionCommand("Aniadir usuario"); this.barra.aniadirUsuario.setActionCommand("Aniadir usuario");
} }

View File

@ -1,5 +1,6 @@
package VistaControlador; package VistaControlador;
import java.awt.Color;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -13,11 +14,32 @@ public class ControladorPanelInterfaz implements ActionListener{
} }
private void aniadirListener() { private void aniadirListener() {
//this.vista. this.vista.aplicarCambios.addActionListener(this);
this.vista.aplicarCambios.setActionCommand("Aplicar cambios");
} }
@Override
public void actionPerformed(ActionEvent arg0) { 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);
}
}
}
} }
} }

View File

@ -31,6 +31,7 @@ import loggin.Vista;
public class Menu extends JFrame{ public class Menu extends JFrame{
static final int VISTA_MODIFICAR = 0; static final int VISTA_MODIFICAR = 0;
static final int VISTA_GESTION = 1; static final int VISTA_GESTION = 1;
static final int VISTA_INTERFAZ =2;
JPanel panelCentral; JPanel panelCentral;
JTabbedPane pestania; JTabbedPane pestania;
@ -50,6 +51,7 @@ public class Menu extends JFrame{
DatePicker elegirMes; DatePicker elegirMes;
int anio; int anio;
Month mes; Month mes;
VistaPanelInterfaz panelInterfaz;
/** /**
* Constructor que carga los datos del menu * Constructor que carga los datos del menu
@ -81,6 +83,7 @@ public class Menu extends JFrame{
this.panelCentral.setLayout(new GridBagLayout()); this.panelCentral.setLayout(new GridBagLayout());
this.panelGestion = new VistaPanelGestion(this.meses); this.panelGestion = new VistaPanelGestion(this.meses);
this.panelModificar = new VistaPanelModificar(); this.panelModificar = new VistaPanelModificar();
this.panelInterfaz = new VistaPanelInterfaz();
this.panel = this.panelGestion; this.panel = this.panelGestion;
constrain.fill = GridBagConstraints.HORIZONTAL; constrain.fill = GridBagConstraints.HORIZONTAL;
@ -103,6 +106,7 @@ public class Menu extends JFrame{
setLocationRelativeTo(null); setLocationRelativeTo(null);
ControladorPanelGestion controlador3 = new ControladorPanelGestion(this.panelGestion, this); ControladorPanelGestion controlador3 = new ControladorPanelGestion(this.panelGestion, this);
ControladorPanelModificar controlador4 = new ControladorPanelModificar(this.panelModificar, this); ControladorPanelModificar controlador4 = new ControladorPanelModificar(this.panelModificar, this);
ControladorPanelInterfaz controlador5 = new ControladorPanelInterfaz(this.panelInterfaz, this);
this.listenerPestania(); this.listenerPestania();
this.elegirMes = new DatePicker(); this.elegirMes = new DatePicker();
@ -370,6 +374,10 @@ public class Menu extends JFrame{
this.panel = this.panelModificar; this.panel = this.panelModificar;
break; break;
} }
case Menu.VISTA_INTERFAZ:{
this.panel = this.panelInterfaz;
break;
}
} }
this.panelCentral.add(this.panel,constrain); this.panelCentral.add(this.panel,constrain);
this.panel.repaint(); this.panel.repaint();

View File

@ -1,12 +1,16 @@
package VistaControlador; package VistaControlador;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JRadioButton; import javax.swing.JRadioButton;
import javax.swing.JRadioButtonMenuItem; import javax.swing.JRadioButtonMenuItem;
public class VistaPanelInterfaz extends VistaPanel{ public class VistaPanelInterfaz extends VistaPanel{
JRadioButtonMenuItem menu; ButtonGroup menu;
JRadioButton temaClaro; JRadioButton temaClaro;
JRadioButton temaRosa; JRadioButton temaRosa;
JRadioButton temaOscuro; JRadioButton temaOscuro;
@ -14,18 +18,34 @@ JCheckBox aplicarBarra;
JButton aplicarCambios; JButton aplicarCambios;
VistaPanelInterfaz() { VistaPanelInterfaz() {
this.menu = new JRadioButtonMenuItem(); this.setLayout(new GridBagLayout());
this.temaClaro = new JRadioButton(); GridBagConstraints constrain = new GridBagConstraints();
this.menu = new ButtonGroup();
this.temaClaro = new JRadioButton("claro");
this.menu.add(this.temaClaro); this.menu.add(this.temaClaro);
this.temaOscuro = new JRadioButton(); this.temaOscuro = new JRadioButton("oscuro");
this.menu.add(this.temaOscuro); this.menu.add(this.temaOscuro);
this.temaRosa = new JRadioButton(); this.temaRosa = new JRadioButton("rosa");
this.menu.add(this.temaRosa); this.menu.add(this.temaRosa);
this.add(this.menu); //this.menu.setSize(200, 200);
this.aplicarBarra = new JCheckBox(); constrain.gridx = 0;
this.add(this.aplicarBarra); 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.aplicarCambios = new JButton("Aplicar");
this.add(this.aplicarCambios); constrain.gridx = 1;
constrain.gridy = 1;
this.add(this.aplicarCambios,constrain);
} }
} }