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/ | ||||
| /PedirDatos/ | ||||
|  | ||||
| @ -2,9 +2,7 @@ package VistaControlador; | ||||
| 
 | ||||
| import java.awt.event.ActionEvent; | ||||
| import java.awt.event.ActionListener; | ||||
| 
 | ||||
| import javax.swing.JFrame; | ||||
| import javax.swing.JTextField; | ||||
| import javax.swing.JOptionPane; | ||||
| 
 | ||||
| public class Controlador implements ActionListener{ | ||||
| 
 | ||||
| @ -15,15 +13,23 @@ public class Controlador implements ActionListener{ | ||||
| 	} | ||||
| 	@Override | ||||
| 	public void actionPerformed(ActionEvent e) { | ||||
| 		String nombre="hola"; | ||||
| 		int dinero=0; | ||||
| 		JFrame pedir=new JFrame(); | ||||
| 		JTextField iNombre=new JTextField("nombre"); | ||||
| 		JTextField iDinero=new JTextField("0"); | ||||
| 		pedir.add(iNombre); | ||||
| 		pedir.add(iDinero); | ||||
| 		//pedir.setVisible(true); | ||||
| 		this.vista.aniadirElemento(iNombre.getText(), Integer.parseInt(iDinero.getText())); | ||||
| 		String nombre=JOptionPane.showInputDialog("Introduce un nuevo gasto o ingreso"); | ||||
| 		if(nombre.equals("")) { | ||||
| 			JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE); | ||||
| 			return; | ||||
| 		} | ||||
| 		String dinero=JOptionPane.showInputDialog("Introduce a cuanto asciende"); | ||||
| 		if(dinero.equals("")) { | ||||
| 			JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE); | ||||
| 			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 javax.swing.JButton; | ||||
| import javax.swing.JComponent; | ||||
| import javax.swing.JFrame; | ||||
| import javax.swing.JPanel; | ||||
| import javax.swing.JTabbedPane; | ||||
| @ -19,12 +17,11 @@ public class Menu extends JFrame{ | ||||
| 	} | ||||
| 	 | ||||
| 	private void init() { | ||||
| 		this.ingresos=new Vista(); | ||||
| 		this.gastos=new Vista(); | ||||
| 		this.ingresos=new Vista(this); | ||||
| 		this.gastos=new Vista(this); | ||||
| 		this.panelCentral=new JPanel(); | ||||
| 		this.pestania=new JTabbedPane(); | ||||
| 		this.panelCentral.add(pestania); | ||||
| 		this.gastos=new Vista(); | ||||
| 		this.pestania.addTab("Ingresos", ingresos); | ||||
| 		this.pestania.addTab("Gastos", gastos); | ||||
| 		getContentPane().add(pestania); | ||||
|  | ||||
| @ -3,6 +3,7 @@ package VistaControlador; | ||||
| import java.awt.Dimension; | ||||
| import javax.swing.JButton; | ||||
| import javax.swing.JCheckBox; | ||||
| import javax.swing.JFrame; | ||||
| import javax.swing.JPanel; | ||||
| import javax.swing.JScrollPane; | ||||
| 
 | ||||
| @ -12,9 +13,10 @@ public class Vista extends JPanel{ | ||||
| 	private int x,y; | ||||
| 	private Gestion gestiones; | ||||
| 	protected JButton boton; | ||||
| 	protected JFrame padre; | ||||
| 	JPanel cuadro; | ||||
| 	JScrollPane panel; | ||||
| 	public Vista() { | ||||
| 	public Vista(JFrame padre) { | ||||
| 		this.x=100; | ||||
| 		this.boton=new JButton("aniadir"); | ||||
| 		this.gestiones=new Gestion(); | ||||
| @ -24,11 +26,11 @@ public class Vista extends JPanel{ | ||||
| 		this.panel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); | ||||
| 		this.panel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); | ||||
| 		cuadro.setPreferredSize(new Dimension(x, y)); | ||||
| 		panel.setPreferredSize(new Dimension(100,400)); | ||||
| 		panel.setPreferredSize(new Dimension(100,200)); | ||||
| 		panel.setVisible(true); | ||||
| 		this.add(panel); | ||||
| 		this.aniadirElemento("asdfa", 0); | ||||
| 		 | ||||
| 		this.padre=padre; | ||||
| 	} | ||||
| 	 | ||||
| 	public void aniadirElemento(String nombre, int dinero) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user