Añadiendo la introducción de datos
This commit is contained in:
		
							parent
							
								
									386e847a27
								
							
						
					
					
						commit
						a6afa6adb6
					
				
							
								
								
									
										3
									
								
								bin/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								bin/.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,3 +1,2 @@ | |||||||
| /Logica/ |  | ||||||
| /Main.class |  | ||||||
| /VistaControlador/ | /VistaControlador/ | ||||||
|  | /PedirDatos/ | ||||||
|  | |||||||
| @ -2,9 +2,7 @@ package VistaControlador; | |||||||
| 
 | 
 | ||||||
| import java.awt.event.ActionEvent; | import java.awt.event.ActionEvent; | ||||||
| import java.awt.event.ActionListener; | import java.awt.event.ActionListener; | ||||||
| 
 | import javax.swing.JOptionPane; | ||||||
| import javax.swing.JFrame; |  | ||||||
| import javax.swing.JTextField; |  | ||||||
| 
 | 
 | ||||||
| public class Controlador implements ActionListener{ | public class Controlador implements ActionListener{ | ||||||
| 
 | 
 | ||||||
| @ -15,15 +13,23 @@ public class Controlador implements ActionListener{ | |||||||
| 	} | 	} | ||||||
| 	@Override | 	@Override | ||||||
| 	public void actionPerformed(ActionEvent e) { | 	public void actionPerformed(ActionEvent e) { | ||||||
| 		String nombre="hola"; | 		String nombre=JOptionPane.showInputDialog("Introduce un nuevo gasto o ingreso"); | ||||||
| 		int dinero=0; | 		if(nombre.equals("")) { | ||||||
| 		JFrame pedir=new JFrame(); | 			JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE); | ||||||
| 		JTextField iNombre=new JTextField("nombre"); | 			return; | ||||||
| 		JTextField iDinero=new JTextField("0"); | 		} | ||||||
| 		pedir.add(iNombre); | 		String dinero=JOptionPane.showInputDialog("Introduce a cuanto asciende"); | ||||||
| 		pedir.add(iDinero); | 		if(dinero.equals("")) { | ||||||
| 		//pedir.setVisible(true); | 			JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE); | ||||||
| 		this.vista.aniadirElemento(iNombre.getText(), Integer.parseInt(iDinero.getText())); | 			return; | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 		try { | ||||||
|  | 			this.vista.aniadirElemento(nombre, Integer.parseInt(dinero)); | ||||||
|  | 		}catch (NumberFormatException ex) { | ||||||
|  | 			JOptionPane.showMessageDialog(null, "Debe introducir un numero", "error", JOptionPane.WARNING_MESSAGE); | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	 | 	 | ||||||
|  | |||||||
| @ -2,8 +2,6 @@ package VistaControlador; | |||||||
| 
 | 
 | ||||||
| import java.awt.Dimension; | import java.awt.Dimension; | ||||||
| 
 | 
 | ||||||
| import javax.swing.JButton; |  | ||||||
| import javax.swing.JComponent; |  | ||||||
| import javax.swing.JFrame; | import javax.swing.JFrame; | ||||||
| import javax.swing.JPanel; | import javax.swing.JPanel; | ||||||
| import javax.swing.JTabbedPane; | import javax.swing.JTabbedPane; | ||||||
| @ -19,12 +17,11 @@ public class Menu extends JFrame{ | |||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	private void init() { | 	private void init() { | ||||||
| 		this.ingresos=new Vista(); | 		this.ingresos=new Vista(this); | ||||||
| 		this.gastos=new Vista(); | 		this.gastos=new Vista(this); | ||||||
| 		this.panelCentral=new JPanel(); | 		this.panelCentral=new JPanel(); | ||||||
| 		this.pestania=new JTabbedPane(); | 		this.pestania=new JTabbedPane(); | ||||||
| 		this.panelCentral.add(pestania); | 		this.panelCentral.add(pestania); | ||||||
| 		this.gastos=new Vista(); |  | ||||||
| 		this.pestania.addTab("Ingresos", ingresos); | 		this.pestania.addTab("Ingresos", ingresos); | ||||||
| 		this.pestania.addTab("Gastos", gastos); | 		this.pestania.addTab("Gastos", gastos); | ||||||
| 		getContentPane().add(pestania); | 		getContentPane().add(pestania); | ||||||
|  | |||||||
| @ -3,6 +3,7 @@ package VistaControlador; | |||||||
| import java.awt.Dimension; | import java.awt.Dimension; | ||||||
| import javax.swing.JButton; | import javax.swing.JButton; | ||||||
| import javax.swing.JCheckBox; | import javax.swing.JCheckBox; | ||||||
|  | import javax.swing.JFrame; | ||||||
| import javax.swing.JPanel; | import javax.swing.JPanel; | ||||||
| import javax.swing.JScrollPane; | import javax.swing.JScrollPane; | ||||||
| 
 | 
 | ||||||
| @ -12,9 +13,10 @@ public class Vista extends JPanel{ | |||||||
| 	private int x,y; | 	private int x,y; | ||||||
| 	private Gestion gestiones; | 	private Gestion gestiones; | ||||||
| 	protected JButton boton; | 	protected JButton boton; | ||||||
|  | 	protected JFrame padre; | ||||||
| 	JPanel cuadro; | 	JPanel cuadro; | ||||||
| 	JScrollPane panel; | 	JScrollPane panel; | ||||||
| 	public Vista() { | 	public Vista(JFrame padre) { | ||||||
| 		this.x=100; | 		this.x=100; | ||||||
| 		this.boton=new JButton("aniadir"); | 		this.boton=new JButton("aniadir"); | ||||||
| 		this.gestiones=new Gestion(); | 		this.gestiones=new Gestion(); | ||||||
| @ -24,11 +26,11 @@ public class Vista extends JPanel{ | |||||||
| 		this.panel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); | 		this.panel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); | ||||||
| 		this.panel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); | 		this.panel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); | ||||||
| 		cuadro.setPreferredSize(new Dimension(x, y)); | 		cuadro.setPreferredSize(new Dimension(x, y)); | ||||||
| 		panel.setPreferredSize(new Dimension(100,400)); | 		panel.setPreferredSize(new Dimension(100,200)); | ||||||
| 		panel.setVisible(true); | 		panel.setVisible(true); | ||||||
| 		this.add(panel); | 		this.add(panel); | ||||||
| 		this.aniadirElemento("asdfa", 0); | 		this.aniadirElemento("asdfa", 0); | ||||||
| 		 | 		this.padre=padre; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public void aniadirElemento(String nombre, int dinero) { | 	public void aniadirElemento(String nombre, int dinero) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user