Aniadido exportar xml
This commit is contained in:
		
							parent
							
								
									8bfab6a9dc
								
							
						
					
					
						commit
						1e46c48068
					
				
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										37
									
								
								src/Ficheros/Configuracion.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/Ficheros/Configuracion.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | |||||||
|  | package Ficheros; | ||||||
|  | 
 | ||||||
|  | import VistaControlador.Menu; | ||||||
|  | 
 | ||||||
|  | import java.io.FileNotFoundException; | ||||||
|  | import java.io.FileReader; | ||||||
|  | import java.io.FileWriter; | ||||||
|  | import java.io.IOException; | ||||||
|  | import java.util.Properties; | ||||||
|  | 
 | ||||||
|  | public class Configuracion { | ||||||
|  | 	private static String direccion=".config"; | ||||||
|  | 	 | ||||||
|  | 	public static void guardarConfiguracion(Menu menu) { | ||||||
|  | 		Properties configuracion = new Properties(); | ||||||
|  | 		configuracion.setProperty("ruta", menu.getRuta()); | ||||||
|  | 		configuracion.setProperty("tema", String.valueOf(menu.getTema())); | ||||||
|  | 		try { | ||||||
|  |             configuracion.store(new FileWriter(Configuracion.direccion), "Configuracion general"); | ||||||
|  |         } catch (IOException e1) { | ||||||
|  |             e1.printStackTrace(); | ||||||
|  |         } | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public static void cargarConfiguracion(Menu menu) throws IOException { | ||||||
|  | 		Properties configuracion = new Properties(); | ||||||
|  | 		try { | ||||||
|  | 			configuracion.load(new FileReader(Configuracion.direccion)); | ||||||
|  | 		} catch (FileNotFoundException e) { | ||||||
|  | 			Configuracion.guardarConfiguracion(menu); | ||||||
|  | 		} | ||||||
|  | 		menu.setTheme(Integer.parseInt(configuracion.getProperty("tema"))); | ||||||
|  | 		configuracion.getProperty("ruta"); | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -1,39 +0,0 @@ | |||||||
| package Ficheros; |  | ||||||
| 
 |  | ||||||
| import java.io.File; |  | ||||||
| import java.io.FileInputStream; |  | ||||||
| import java.io.FileNotFoundException; |  | ||||||
| import java.io.FileOutputStream; |  | ||||||
| import java.io.IOException; |  | ||||||
| import java.io.ObjectInputStream; |  | ||||||
| import java.io.ObjectOutputStream; |  | ||||||
| 
 |  | ||||||
| import Logica.Gestion; |  | ||||||
| import Logica.Meses; |  | ||||||
| 
 |  | ||||||
| public class FicheroBinario { |  | ||||||
| 	String directorioGestiones; |  | ||||||
| 	String directorioTransacciones; |  | ||||||
| 	String directorioMeses; |  | ||||||
| 	public FicheroBinario(String nombre) { |  | ||||||
| 		this.directorioGestiones=nombre; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void guardarMeses(Meses mes) { |  | ||||||
| 		 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void guardarGestiones(Gestion gestion) throws IOException { |  | ||||||
| 		FileOutputStream ficheroSalida = new FileOutputStream(new File(this.directorioGestiones)); |  | ||||||
| 		ObjectOutputStream escritor = new ObjectOutputStream(ficheroSalida); |  | ||||||
| 		escritor.writeObject(gestion); |  | ||||||
| 		escritor.close(); |  | ||||||
| 		ficheroSalida.close(); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void cargarGestiones(Meses meses) throws IOException { |  | ||||||
| 		FileInputStream ficheroEntrada = new FileInputStream(new File(this.directorioGestiones)); |  | ||||||
| 		ObjectInputStream lector = new ObjectInputStream(ficheroEntrada); |  | ||||||
| 		//meses.aniadirGestion(nombre, anio, mes, isPositivo) |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,6 +1,7 @@ | |||||||
| package Logica; | package Logica; | ||||||
| 
 | 
 | ||||||
| import java.io.EOFException; | import java.io.EOFException; | ||||||
|  | import java.io.File; | ||||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||||
| @ -12,6 +13,24 @@ import java.time.Month; | |||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.Vector; | import java.util.Vector; | ||||||
| 
 | 
 | ||||||
|  | import javax.xml.parsers.DocumentBuilder; | ||||||
|  | import javax.xml.parsers.DocumentBuilderFactory; | ||||||
|  | import javax.xml.parsers.ParserConfigurationException; | ||||||
|  | import javax.xml.transform.Result; | ||||||
|  | import javax.xml.transform.Source; | ||||||
|  | import javax.xml.transform.Transformer; | ||||||
|  | import javax.xml.transform.TransformerConfigurationException; | ||||||
|  | import javax.xml.transform.TransformerException; | ||||||
|  | import javax.xml.transform.TransformerFactory; | ||||||
|  | import javax.xml.transform.TransformerFactoryConfigurationError; | ||||||
|  | import javax.xml.transform.dom.DOMSource; | ||||||
|  | import javax.xml.transform.stream.StreamResult; | ||||||
|  | 
 | ||||||
|  | import org.w3c.dom.DOMImplementation; | ||||||
|  | import org.w3c.dom.Document; | ||||||
|  | import org.w3c.dom.Element; | ||||||
|  | import org.w3c.dom.Text; | ||||||
|  | 
 | ||||||
| public class Meses { | public class Meses { | ||||||
| 	private ArrayList<Mes> meses; | 	private ArrayList<Mes> meses; | ||||||
| 	private int mesActual=0; | 	private int mesActual=0; | ||||||
| @ -124,6 +143,96 @@ public class Meses { | |||||||
| 		return ret; | 		return ret; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	public void exportarXML() { | ||||||
|  | 		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); | ||||||
|  | 		DocumentBuilder builder; | ||||||
|  | 		File fichero = new File("gestiones.xml"); | ||||||
|  | 		try { | ||||||
|  | 			builder = factory.newDocumentBuilder(); | ||||||
|  | 			DOMImplementation dom = builder.getDOMImplementation(); | ||||||
|  | 			Document documento = dom.createDocument(null, "xml", null); | ||||||
|  | 			Element raiz = documento.createElement("raiz"); | ||||||
|  | 			documento.getDocumentElement().appendChild(raiz); | ||||||
|  | 			Element nodoMeses; | ||||||
|  | 			Element nodoGestion; | ||||||
|  | 			Element nodoTransaccion; | ||||||
|  | 			Element nodoDatos; | ||||||
|  | 			Text dato; | ||||||
|  | 			for(Mes mes:this.meses) { | ||||||
|  | 				nodoMeses = documento.createElement("mes"); | ||||||
|  | 				raiz.appendChild(nodoMeses); | ||||||
|  | 				nodoDatos = documento.createElement("nombre"); | ||||||
|  | 				nodoMeses.appendChild(nodoDatos); | ||||||
|  | 				dato = documento.createTextNode(mes.getMes().toString()); | ||||||
|  | 				nodoDatos.appendChild(dato); | ||||||
|  | 				nodoDatos = documento.createElement("anio"); | ||||||
|  | 				nodoMeses.appendChild(nodoDatos); | ||||||
|  | 				dato = documento.createTextNode(String.valueOf(mes.getAnio())); | ||||||
|  | 				nodoDatos.appendChild(dato); | ||||||
|  | 				nodoDatos = documento.createElement("dineroRestante"); | ||||||
|  | 				nodoMeses.appendChild(nodoDatos); | ||||||
|  | 				dato = documento.createTextNode(String.valueOf(mes.getTotal())); | ||||||
|  | 				nodoDatos.appendChild(dato); | ||||||
|  | 				nodoDatos = documento.createElement("numeroGestiones"); | ||||||
|  | 				nodoMeses.appendChild(nodoDatos); | ||||||
|  | 				dato = documento.createTextNode(String.valueOf(mes.nGestiones)); | ||||||
|  | 				nodoDatos.appendChild(dato); | ||||||
|  | 				for(Gestion gestion:mes.gestiones) { | ||||||
|  | 					nodoGestion = documento.createElement("gestion"); | ||||||
|  | 					nodoMeses.appendChild(nodoGestion); | ||||||
|  | 					nodoDatos = documento.createElement("Nombre"); | ||||||
|  | 					nodoGestion.appendChild(nodoDatos); | ||||||
|  | 					dato = documento.createTextNode(gestion.getNombre()); | ||||||
|  | 					nodoDatos.appendChild(dato); | ||||||
|  | 					nodoDatos = documento.createElement("Dinero"); | ||||||
|  | 					nodoGestion.appendChild(nodoDatos); | ||||||
|  | 					dato = documento.createTextNode(String.valueOf(gestion.getSuma())); | ||||||
|  | 					nodoDatos.appendChild(dato); | ||||||
|  | 					nodoDatos = documento.createElement("EsPositivo"); | ||||||
|  | 					nodoGestion.appendChild(nodoDatos); | ||||||
|  | 					dato = documento.createTextNode(String.valueOf(gestion.esIngreso())); | ||||||
|  | 					nodoDatos.appendChild(dato); | ||||||
|  | 					for(Transaccion transaccion:gestion.getElementos()) { | ||||||
|  | 						nodoTransaccion = documento.createElement("transaccion"); | ||||||
|  | 						nodoGestion.appendChild(nodoTransaccion); | ||||||
|  | 						nodoDatos = documento.createElement("Nombre"); | ||||||
|  | 						nodoTransaccion.appendChild(nodoDatos); | ||||||
|  | 						dato = documento.createTextNode(transaccion.getNombre()); | ||||||
|  | 						nodoTransaccion.appendChild(dato); | ||||||
|  | 						nodoDatos = documento.createElement("Fecha"); | ||||||
|  | 						nodoTransaccion.appendChild(nodoDatos); | ||||||
|  | 						dato = documento.createTextNode(transaccion.getDia().toString()); | ||||||
|  | 						nodoTransaccion.appendChild(dato); | ||||||
|  | 						nodoDatos = documento.createElement("Dinero"); | ||||||
|  | 						nodoTransaccion.appendChild(nodoDatos); | ||||||
|  | 						dato = documento.createTextNode(String.valueOf(transaccion.getDinero())); | ||||||
|  | 						nodoTransaccion.appendChild(dato); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			Source src = new DOMSource(documento); | ||||||
|  |             Result result = new StreamResult(fichero); | ||||||
|  | 
 | ||||||
|  |             Transformer transformer = null; | ||||||
|  |             transformer = TransformerFactory.newInstance().newTransformer(); | ||||||
|  |             transformer.transform(src, result); | ||||||
|  | 			 | ||||||
|  | 		} catch (ParserConfigurationException e) { | ||||||
|  | 			// TODO Auto-generated catch block | ||||||
|  | 			e.printStackTrace(); | ||||||
|  | 		} catch (TransformerConfigurationException e) { | ||||||
|  | 			// TODO Auto-generated catch block | ||||||
|  | 			e.printStackTrace(); | ||||||
|  | 		} catch (TransformerFactoryConfigurationError e) { | ||||||
|  | 			// TODO Auto-generated catch block | ||||||
|  | 			e.printStackTrace(); | ||||||
|  | 		} catch (TransformerException e) { | ||||||
|  | 			// TODO Auto-generated catch block | ||||||
|  | 			e.printStackTrace(); | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| class Mes implements Serializable{ | class Mes implements Serializable{ | ||||||
|  | |||||||
| @ -4,9 +4,6 @@ import java.io.Serializable; | |||||||
| import java.time.LocalDate; | import java.time.LocalDate; | ||||||
| 
 | 
 | ||||||
| public class Transaccion implements Serializable{ | public class Transaccion implements Serializable{ | ||||||
| 	/** |  | ||||||
| 	 *  |  | ||||||
| 	 */ |  | ||||||
| 	private static final long serialVersionUID = 7544113192927092049L; | 	private static final long serialVersionUID = 7544113192927092049L; | ||||||
| 	private String nombre; | 	private String nombre; | ||||||
| 	private float dinero; | 	private float dinero; | ||||||
| @ -50,4 +47,8 @@ public class Transaccion implements Serializable{ | |||||||
| 	public Gestion getGestion() { | 	public Gestion getGestion() { | ||||||
| 		return this.gestion; | 		return this.gestion; | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
|  | 	public String getNombre() { | ||||||
|  | 		return this.nombre; | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -10,6 +10,7 @@ public class BarraOpciones extends JMenuBar{ | |||||||
| 	JMenu menuAr; | 	JMenu menuAr; | ||||||
| 	JMenuItem cambiarRuta; | 	JMenuItem cambiarRuta; | ||||||
| 	JMenuItem guardarIns; | 	JMenuItem guardarIns; | ||||||
|  | 	JMenuItem exportarXML; | ||||||
| 	JMenu interfaz; | 	JMenu interfaz; | ||||||
| 	JMenuItem modoOscuro; | 	JMenuItem modoOscuro; | ||||||
| 	JMenuItem modoRosa; | 	JMenuItem modoRosa; | ||||||
| @ -23,6 +24,8 @@ public class BarraOpciones extends JMenuBar{ | |||||||
| 		this.menuAr.add(this.guardarIns); | 		this.menuAr.add(this.guardarIns); | ||||||
| 		this.cambiarRuta = new JMenuItem("Cambiar ruta de guardado"); | 		this.cambiarRuta = new JMenuItem("Cambiar ruta de guardado"); | ||||||
| 		this.menuAr.add(this.cambiarRuta); | 		this.menuAr.add(this.cambiarRuta); | ||||||
|  | 		this.exportarXML = new JMenuItem("Exportar en un XML"); | ||||||
|  | 		this.menuAr.add(this.exportarXML); | ||||||
| 		this.interfaz = new JMenu("Interfaz"); | 		this.interfaz = new JMenu("Interfaz"); | ||||||
| 		this.add(this.interfaz); | 		this.add(this.interfaz); | ||||||
| 		this.modoClaro = new JMenuItem("Modo claro"); | 		this.modoClaro = new JMenuItem("Modo claro"); | ||||||
|  | |||||||
| @ -1,12 +1,13 @@ | |||||||
| 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; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| 
 | 
 | ||||||
| import javax.swing.JOptionPane; | import javax.swing.JOptionPane; | ||||||
| 
 | 
 | ||||||
|  | import Ficheros.Configuracion; | ||||||
|  | 
 | ||||||
| public class ControladorBarra implements ActionListener{ | public class ControladorBarra implements ActionListener{ | ||||||
| 	private BarraOpciones barra; | 	private BarraOpciones barra; | ||||||
| 	private Menu menu; | 	private Menu menu; | ||||||
| @ -26,7 +27,8 @@ public class ControladorBarra implements ActionListener{ | |||||||
| 					JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE); | 					JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE); | ||||||
| 					return; | 					return; | ||||||
| 				} | 				} | ||||||
| 				this.menu.nombreDatos = ruta; | 				this.menu.rutaGuardado = ruta; | ||||||
|  | 				Configuracion.guardarConfiguracion(this.menu); | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
| 			case "Guardar instantanea":{ | 			case "Guardar instantanea":{ | ||||||
| @ -45,46 +47,15 @@ public class ControladorBarra implements ActionListener{ | |||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
| 			case "Modo claro":{ | 			case "Modo claro":{ | ||||||
| 				this.menu.setBackground(Color.WHITE); | 				menu.setTheme(0); | ||||||
| 				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; | 				break; | ||||||
| 			} | 			} | ||||||
| 			case "Modo rosa":{ | 			case "Modo rosa":{ | ||||||
| 				this.menu.setBackground(Color.PINK); | 				menu.setTheme(1); | ||||||
| 				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; | 				break; | ||||||
| 			} | 			} | ||||||
| 			case "Modo oscuro":{ | 			case "Modo oscuro":{ | ||||||
| 				this.menu.setBackground(Color.BLACK); | 				menu.setTheme(2); | ||||||
| 				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; | 				break; | ||||||
| 			} | 			} | ||||||
| 			case "Mostrar todo":{ | 			case "Mostrar todo":{ | ||||||
| @ -92,6 +63,9 @@ public class ControladorBarra implements ActionListener{ | |||||||
| 				mostrar.setVisible(true); | 				mostrar.setVisible(true); | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
|  | 			case "Exportar XLM":{ | ||||||
|  | 				this.menu.meses.exportarXML(); | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 	} | 	} | ||||||
| @ -101,6 +75,8 @@ public class ControladorBarra implements ActionListener{ | |||||||
| 		this.barra.cambiarRuta.setActionCommand("Cambiar ruta"); | 		this.barra.cambiarRuta.setActionCommand("Cambiar ruta"); | ||||||
| 		this.barra.guardarIns.addActionListener(this); | 		this.barra.guardarIns.addActionListener(this); | ||||||
| 		this.barra.guardarIns.setActionCommand("Guardar instantanea"); | 		this.barra.guardarIns.setActionCommand("Guardar instantanea"); | ||||||
|  | 		this.barra.exportarXML.addActionListener(this); | ||||||
|  | 		this.barra.exportarXML.setActionCommand("Exportar XLM"); | ||||||
| 		this.barra.modoClaro.addActionListener(this); | 		this.barra.modoClaro.addActionListener(this); | ||||||
| 		this.barra.modoClaro.setActionCommand("Modo claro"); | 		this.barra.modoClaro.setActionCommand("Modo claro"); | ||||||
| 		this.barra.modoRosa.addActionListener(this); | 		this.barra.modoRosa.addActionListener(this); | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| package VistaControlador; | package VistaControlador; | ||||||
| 
 | 
 | ||||||
|  | import java.awt.Color; | ||||||
| import java.awt.Dimension; | import java.awt.Dimension; | ||||||
| import java.awt.GridBagConstraints; | import java.awt.GridBagConstraints; | ||||||
| import java.awt.GridBagLayout; | import java.awt.GridBagLayout; | ||||||
| @ -18,6 +19,7 @@ import javax.swing.JTextArea; | |||||||
| import javax.swing.event.ChangeEvent; | import javax.swing.event.ChangeEvent; | ||||||
| import javax.swing.event.ChangeListener; | import javax.swing.event.ChangeListener; | ||||||
| 
 | 
 | ||||||
|  | import Ficheros.Configuracion; | ||||||
| import Logica.Gestion; | import Logica.Gestion; | ||||||
| import Logica.Meses; | import Logica.Meses; | ||||||
| import Logica.Transaccion; | import Logica.Transaccion; | ||||||
| @ -28,7 +30,8 @@ public class Menu extends JFrame{ | |||||||
| 	protected VistaAniadirVisualizar ingresos; | 	protected VistaAniadirVisualizar ingresos; | ||||||
| 	protected VistaAniadirVisualizar gastos; | 	protected VistaAniadirVisualizar gastos; | ||||||
| 	protected VistaPanelLateral panel; | 	protected VistaPanelLateral panel; | ||||||
| 	String nombreDatos; | 	String rutaGuardado; | ||||||
|  | 	int tema; | ||||||
| 	Meses meses; | 	Meses meses; | ||||||
| 	ArrayList<VistaAniadirVisualizar> pestanias; | 	ArrayList<VistaAniadirVisualizar> pestanias; | ||||||
| 	ArrayList<ControladorAniadirVisualizar> controladores; | 	ArrayList<ControladorAniadirVisualizar> controladores; | ||||||
| @ -36,9 +39,11 @@ public class Menu extends JFrame{ | |||||||
| 	protected Gestion datosGastos; | 	protected Gestion datosGastos; | ||||||
| 	protected Gestion datosIngresos; | 	protected Gestion datosIngresos; | ||||||
| 	public Menu() { | 	public Menu() { | ||||||
|  | 		this.rutaGuardado = ".mes"; | ||||||
|  | 		this.tema = 0; | ||||||
| 		this.barra = new BarraOpciones(); | 		this.barra = new BarraOpciones(); | ||||||
| 		ControladorBarra controladorBarra = new ControladorBarra(barra, this); | 		ControladorBarra controladorBarra = new ControladorBarra(barra, this); | ||||||
| 		this.nombreDatos = ".mes"; | 		 | ||||||
| 		setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); | 		setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); | ||||||
| 		  | 		  | ||||||
|         addWindowListener(new java.awt.event.WindowAdapter() { |         addWindowListener(new java.awt.event.WindowAdapter() { | ||||||
| @ -79,13 +84,19 @@ public class Menu extends JFrame{ | |||||||
| 		constrain.weightx = 0.25; | 		constrain.weightx = 0.25; | ||||||
| 		this.panelCentral.add(this.panel,constrain); | 		this.panelCentral.add(this.panel,constrain); | ||||||
| 		this.add(this.panelCentral); | 		this.add(this.panelCentral); | ||||||
|  | 		try { | ||||||
|  | 			Configuracion.cargarConfiguracion(this); | ||||||
|  | 		} catch (IOException e) { | ||||||
|  | 			e.printStackTrace(); | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	private void close(){ | 	private void close(){ | ||||||
|         if (JOptionPane.showConfirmDialog(rootPane, "¿Desea guardar el estado?", |         if (JOptionPane.showConfirmDialog(rootPane, "¿Desea guardar el estado?", | ||||||
|                 "Salir del sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { |                 "Salir del sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { | ||||||
|         	try { |         	try { | ||||||
| 				this.meses.guardarMeses(this.nombreDatos); | 				this.meses.guardarMeses(this.rutaGuardado); | ||||||
|  | 				Configuracion.guardarConfiguracion(this); | ||||||
| 			} catch (IOException e) { | 			} catch (IOException e) { | ||||||
| 				// TODO Auto-generated catch block | 				// TODO Auto-generated catch block | ||||||
| 				e.printStackTrace(); | 				e.printStackTrace(); | ||||||
| @ -112,7 +123,7 @@ public class Menu extends JFrame{ | |||||||
| 		if(this.meses==null) { | 		if(this.meses==null) { | ||||||
| 			this.meses=new Meses(); | 			this.meses=new Meses(); | ||||||
| 			try { | 			try { | ||||||
| 				meses.cargarMeses(this.nombreDatos); | 				meses.cargarMeses(this.rutaGuardado); | ||||||
| 			} catch (ClassNotFoundException e) { | 			} catch (ClassNotFoundException e) { | ||||||
| 				// TODO Auto-generated catch block | 				// TODO Auto-generated catch block | ||||||
| 				e.printStackTrace(); | 				e.printStackTrace(); | ||||||
| @ -180,8 +191,70 @@ public class Menu extends JFrame{ | |||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 			}); | 			}); | ||||||
|  | 		}	 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public String getRuta() { | ||||||
|  | 		return this.rutaGuardado; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public void setRuta(String ruta) { | ||||||
|  | 		this.rutaGuardado=ruta; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public int getTema() { | ||||||
|  | 		return this.tema; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public void setTheme(int tema) { | ||||||
|  | 		switch(tema) { | ||||||
|  | 		case 0:{ | ||||||
|  | 			this.tema = 0; | ||||||
|  | 			this.setBackground(Color.WHITE); | ||||||
|  | 			this.setOpacity(1); | ||||||
|  | 			this.repaint(); | ||||||
|  | 			this.revalidate(); | ||||||
|  | 			this.panelCentral.setOpaque(true); | ||||||
|  | 			this.panelCentral.setBackground(Color.WHITE); | ||||||
|  | 			this.panelCentral.repaint(); | ||||||
|  | 			this.panelCentral.revalidate(); | ||||||
|  | 			this.panel.setBackground(Color.WHITE); | ||||||
|  | 			this.panel.repaint(); | ||||||
|  | 			this.panel.revalidate(); | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 		case 1:{ | ||||||
|  | 			this.tema = 1; | ||||||
|  | 			this.setBackground(Color.PINK); | ||||||
|  | 			this.setOpacity(1); | ||||||
|  | 			this.repaint(); | ||||||
|  | 			this.revalidate(); | ||||||
|  | 			this.panelCentral.setOpaque(true); | ||||||
|  | 			this.panelCentral.setBackground(Color.PINK); | ||||||
|  | 			this.panelCentral.repaint(); | ||||||
|  | 			this.panelCentral.revalidate(); | ||||||
|  | 			this.panel.setBackground(Color.PINK); | ||||||
|  | 			this.panel.repaint(); | ||||||
|  | 			this.panel.revalidate(); | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 		case 2:{ | ||||||
|  | 			this.tema = 2; | ||||||
|  | 			this.setBackground(Color.BLACK); | ||||||
|  | 			this.setOpacity(1); | ||||||
|  | 			this.repaint(); | ||||||
|  | 			this.revalidate(); | ||||||
|  | 			this.panelCentral.setOpaque(true); | ||||||
|  | 			this.panelCentral.setBackground(Color.BLACK); | ||||||
|  | 			this.panelCentral.repaint(); | ||||||
|  | 			this.panelCentral.revalidate(); | ||||||
|  | 			this.panel.setBackground(Color.BLACK); | ||||||
|  | 			this.panel.repaint(); | ||||||
|  | 			this.panel.revalidate(); | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 		default: return; | ||||||
| 		} | 		} | ||||||
| 		 |  | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user