Aniadida barra y funcionalidades extra
This commit is contained in:
114
src/VistaControlador/ControladorBarra.java
Normal file
114
src/VistaControlador/ControladorBarra.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package VistaControlador;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class ControladorBarra implements ActionListener{
|
||||
private BarraOpciones barra;
|
||||
private Menu menu;
|
||||
public ControladorBarra(BarraOpciones barra, Menu menu) {
|
||||
this.barra = barra;
|
||||
this.menu = menu;
|
||||
this.aniadirListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch(e.getActionCommand()) {
|
||||
case "Cambiar ruta":{
|
||||
String ruta = JOptionPane.showInputDialog("Introduce la nuev a ruta");
|
||||
if(ruta == null) return;
|
||||
if(ruta.equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE);
|
||||
return;
|
||||
}
|
||||
this.menu.nombreDatos = ruta;
|
||||
break;
|
||||
}
|
||||
case "Guardar instantanea":{
|
||||
String ruta = JOptionPane.showInputDialog("Introduce la ruta de la instantanea");
|
||||
if(ruta == null) return;
|
||||
if(ruta.equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.menu.meses.guardarMeses(ruta);
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
System.out.println("Fichero invalido");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "Modo claro":{
|
||||
this.menu.setBackground(Color.WHITE);
|
||||
this.menu.setOpacity(1);
|
||||
this.menu.repaint();
|
||||
this.menu.revalidate();
|
||||
this.menu.panelCentral.setOpaque(true);
|
||||
this.menu.panelCentral.setBackground(Color.WHITE);
|
||||
this.menu.panelCentral.repaint();
|
||||
this.menu.panelCentral.revalidate();
|
||||
this.menu.panel.setBackground(Color.WHITE);
|
||||
this.menu.panel.repaint();
|
||||
this.menu.panel.revalidate();
|
||||
break;
|
||||
}
|
||||
case "Modo rosa":{
|
||||
this.menu.setBackground(Color.PINK);
|
||||
this.menu.setOpacity(1);
|
||||
this.menu.repaint();
|
||||
this.menu.revalidate();
|
||||
this.menu.panelCentral.setOpaque(true);
|
||||
this.menu.panelCentral.setBackground(Color.PINK);
|
||||
this.menu.panelCentral.repaint();
|
||||
this.menu.panelCentral.revalidate();
|
||||
this.menu.panel.setOpaque(true);
|
||||
this.menu.panel.setBackground(Color.PINK);
|
||||
this.menu.panel.repaint();
|
||||
this.menu.panel.revalidate();
|
||||
break;
|
||||
}
|
||||
case "Modo oscuro":{
|
||||
this.menu.setBackground(Color.BLACK);
|
||||
this.menu.repaint();
|
||||
this.menu.revalidate();
|
||||
this.menu.panelCentral.setOpaque(true);
|
||||
this.menu.panelCentral.setBackground(Color.BLACK);
|
||||
this.menu.panelCentral.repaint();
|
||||
this.menu.panelCentral.revalidate();
|
||||
this.menu.panel.setOpaque(true);
|
||||
this.menu.panel.setBackground(Color.BLACK);
|
||||
this.menu.panel.repaint();
|
||||
this.menu.panel.revalidate();
|
||||
break;
|
||||
}
|
||||
case "Mostrar todo":{
|
||||
MostrarTodo mostrar = new MostrarTodo(this.menu.meses);
|
||||
mostrar.setVisible(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void aniadirListeners() {
|
||||
this.barra.cambiarRuta.addActionListener(this);
|
||||
this.barra.cambiarRuta.setActionCommand("Cambiar ruta");
|
||||
this.barra.guardarIns.addActionListener(this);
|
||||
this.barra.guardarIns.setActionCommand("Guardar instantanea");
|
||||
this.barra.modoClaro.addActionListener(this);
|
||||
this.barra.modoClaro.setActionCommand("Modo claro");
|
||||
this.barra.modoRosa.addActionListener(this);
|
||||
this.barra.modoRosa.setActionCommand("Modo rosa");
|
||||
this.barra.modoOscuro.addActionListener(this);
|
||||
this.barra.modoOscuro.setActionCommand("Modo oscuro");
|
||||
this.barra.mostrarTodo.addActionListener(this);
|
||||
this.barra.mostrarTodo.setActionCommand("Mostrar todo");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user