GreysitoErPutoAmo

JFrame Cuenta Bancaria - Actualizado

Mar 6th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.87 KB | None | 0 0
  1. import java.awt.event.ActionEvent;
  2. import java.awt.event.ActionListener;
  3. import java.awt.event.WindowAdapter;
  4. import java.awt.event.WindowEvent;
  5. import javax.swing.JButton;
  6. import javax.swing.JDialog;
  7. import javax.swing.JFrame;
  8. import javax.swing.JLabel;
  9. import javax.swing.JTextField;
  10. import javax.swing.WindowConstants;
  11. import java.awt.Dimension;
  12.  
  13. public class jframecb {
  14.    
  15.     private JFrame ventanaPrincipal;
  16.     private JDialog ventanaCrear;
  17.     private JDialog ventanaIngresar;
  18.     private JDialog ventanaSacar;
  19.     private JDialog ventanaActualizar;
  20.     /**
  21.      * @param args
  22.      */
  23.     public static void main(String[] args) {
  24.         new jframecb();
  25.     }
  26.    
  27.     public jframecb()
  28.     {
  29.         // Construcción de ventana principal
  30.         ventanaPrincipal = new JFrame("Ventana principal");
  31.         ventanaPrincipal.setMinimumSize(new Dimension(800, 600));
  32.         ventanaPrincipal.setAutoRequestFocus(false);
  33.         ventanaPrincipal.setResizable(false);
  34.        
  35.         JButton boton1 = new JButton("Crear Cuenta");
  36.         boton1.setBounds(156, 116, 483, 23);
  37.         JButton boton2 = new JButton("Ingresar Dinero");
  38.         boton2.setBounds(156, 315, 483, 23);
  39.         JButton boton3 = new JButton("Sacar Dinero");
  40.         boton3.setBounds(156, 349, 483, 23);
  41.         JButton boton4 = new JButton("Actualizar Saldo");
  42.         boton4.setBounds(156, 383, 483, 23);
  43.        
  44.         ventanaPrincipal.getContentPane().setLayout(null);
  45.         ventanaPrincipal.getContentPane().add(boton1);
  46.         ventanaPrincipal.getContentPane().add(boton2);
  47.         ventanaPrincipal.getContentPane().add(boton3);
  48.         ventanaPrincipal.getContentPane().add(boton4);
  49.         ventanaPrincipal.pack();
  50.  
  51.         // Construcción de ventana para Crear Cuenta
  52.         ventanaCrear = new JDialog(ventanaPrincipal,"Crear Cuenta");
  53.         ventanaCrear.setMinimumSize(new Dimension(800, 600));
  54.         ventanaCrear.getContentPane().setLayout(null);
  55.        
  56.             JTextField textField = new JTextField();
  57.             textField.setBounds(340, 43, 280, 20);
  58.             ventanaCrear.getContentPane().add(textField);
  59.             textField.setColumns(10);
  60.        
  61.             JTextField textField_1 = new JTextField();
  62.             textField_1.setBounds(340, 74, 280, 20);
  63.             ventanaCrear.getContentPane().add(textField_1);
  64.             textField_1.setColumns(10);
  65.            
  66.             JTextField textField_2 = new JTextField();
  67.             textField_2.setBounds(340, 105, 280, 20);
  68.             ventanaCrear.getContentPane().add(textField_2);
  69.             textField_2.setColumns(10);
  70.            
  71.             JTextField textField_3 = new JTextField();
  72.             textField_3.setBounds(340, 136, 280, 20);
  73.             ventanaCrear.getContentPane().add(textField_3);
  74.             textField_3.setColumns(10);
  75.            
  76.             JTextField textField_4 = new JTextField();
  77.             textField_4.setEditable(false);
  78.             textField_4.setBounds(340, 167, 280, 20);
  79.             ventanaCrear.getContentPane().add(textField_4);
  80.             textField_4.setColumns(10);
  81.            
  82.             JTextField textField_5 = new JTextField();
  83.             textField_5.setBounds(340, 198, 280, 20);
  84.             ventanaCrear.getContentPane().add(textField_5);
  85.             textField_5.setColumns(10);
  86.            
  87.             JTextField textField_6 = new JTextField();
  88.             textField_6.setBounds(340, 229, 280, 20);
  89.             ventanaCrear.getContentPane().add(textField_6);
  90.             textField_6.setColumns(10);
  91.            
  92.             JButton btnCrearCuenta = new JButton("Crear Cuenta");
  93.             btnCrearCuenta.setBounds(340, 319, 280, 20);
  94.             ventanaCrear.getContentPane().add(btnCrearCuenta);
  95.            
  96.             JLabel lblNombreDelTitular = new JLabel("Nombre del titular");
  97.             lblNombreDelTitular.setBounds(130, 46, 200, 14);
  98.             ventanaCrear.getContentPane().add(lblNombreDelTitular);
  99.            
  100.             JLabel lblApellidos = new JLabel("Apellidos");
  101.             lblApellidos.setBounds(130, 77, 200, 14);
  102.             ventanaCrear.getContentPane().add(lblApellidos);
  103.            
  104.             JLabel lblDni = new JLabel("DNI");
  105.             lblDni.setBounds(130, 108, 200, 14);
  106.             ventanaCrear.getContentPane().add(lblDni);
  107.            
  108.             JLabel lblTelefono = new JLabel("Telefono");
  109.             lblTelefono.setBounds(130, 139, 200, 14);
  110.             ventanaCrear.getContentPane().add(lblTelefono);
  111.            
  112.             JLabel lblNumeroDeCuenta = new JLabel("Numero de cuenta");
  113.             lblNumeroDeCuenta.setBounds(130, 170, 200, 14);
  114.             ventanaCrear.getContentPane().add(lblNumeroDeCuenta);
  115.            
  116.             JLabel lblCantidadDeDinero = new JLabel("Cantidad de dinero");
  117.             lblCantidadDeDinero.setBounds(130, 201, 200, 14);
  118.             ventanaCrear.getContentPane().add(lblCantidadDeDinero);
  119.            
  120.             JLabel lblIntersAnual = new JLabel("Inter\u00E9s anual");
  121.             lblIntersAnual.setBounds(130, 232, 200, 14);
  122.             ventanaCrear.getContentPane().add(lblIntersAnual);
  123.        
  124.         // Constructor de ventana para Ingresar Dinero
  125.         ventanaIngresar = new JDialog(ventanaPrincipal, "Ingresar Dinero");
  126.         ventanaIngresar.setMinimumSize(new Dimension(800, 600));
  127.         ventanaIngresar.getContentPane().setLayout(null);
  128.    
  129.             JTextField textFieldid = new JTextField();
  130.             textFieldid.setBounds(156, 187, 177, 20);
  131.             ventanaIngresar.getContentPane().add(textFieldid);
  132.             textFieldid.setColumns(10);
  133.                
  134.             JTextField textField_1id = new JTextField();
  135.             textField_1id.setBounds(156, 233, 177, 20);
  136.             ventanaIngresar.getContentPane().add(textField_1id);
  137.             textField_1id.setColumns(10);
  138.                
  139.             JLabel lblNumeroDeCuentaid = new JLabel("Numero de cuenta");
  140.             lblNumeroDeCuentaid.setBounds(47, 190, 99, 14);
  141.             ventanaIngresar.getContentPane().add(lblNumeroDeCuentaid);
  142.                
  143.             JLabel lblCantidadAIngresarid = new JLabel("Cantidad a ingresar");
  144.             lblCantidadAIngresarid.setBounds(47, 236, 99, 14);
  145.             ventanaIngresar.getContentPane().add(lblCantidadAIngresarid);
  146.                
  147.             JButton btnIngresarid = new JButton("Ingresar");
  148.             btnIngresarid.setBounds(344, 208, 89, 23);
  149.             ventanaIngresar.getContentPane().add(btnIngresarid);
  150.                
  151.             JTextField textField_2id = new JTextField();
  152.             textField_2id.setEditable(false);
  153.             textField_2id.setBounds(482, 209, 170, 20);
  154.             ventanaIngresar.getContentPane().add(textField_2id);
  155.             textField_2id.setColumns(10);
  156.                
  157.             JLabel SaldoActual = new JLabel("Saldo actual");
  158.             SaldoActual.setBounds(531, 166, 89, 14);
  159.             ventanaIngresar.getContentPane().add(SaldoActual);
  160.        
  161.         // Constructor de ventana para Sacar Dinero
  162.         ventanaSacar = new JDialog(ventanaPrincipal, "Sacar Dinero");
  163.         ventanaSacar.setMinimumSize(new Dimension(800, 600));
  164.         ventanaSacar.getContentPane().setLayout(null);
  165.        
  166.             JLabel lblNumeroDeCuentasd = new JLabel("Numero de cuenta");
  167.             lblNumeroDeCuentasd.setBounds(47, 190, 99, 14);
  168.             ventanaSacar.getContentPane().add(lblNumeroDeCuentasd);
  169.                
  170.             JLabel lblCantidadARetirarsd = new JLabel("Cantidad a retirar");
  171.             lblCantidadARetirarsd.setBounds(47, 236, 99, 14);
  172.             ventanaSacar.getContentPane().add(lblCantidadARetirarsd);
  173.        
  174.             JTextField textFieldsd = new JTextField();
  175.             textFieldsd.setBounds(156, 187, 177, 20);
  176.             ventanaSacar.getContentPane().add(textFieldsd);
  177.             textFieldsd.setColumns(10);
  178.        
  179.             JTextField textField_1sd = new JTextField();
  180.             textField_1sd.setBounds(156, 233, 177, 20);
  181.             ventanaSacar.getContentPane().add(textField_1sd);
  182.             textField_1sd.setColumns(10);
  183.        
  184.             JButton btnRetirarsd = new JButton("Retirar");
  185.             btnRetirarsd.setBounds(344, 208, 89, 23);
  186.             ventanaSacar.getContentPane().add(btnRetirarsd);
  187.        
  188.             JTextField textField_2sd = new JTextField();
  189.             textField_2sd.setEditable(false);
  190.             textField_2sd.setBounds(482, 209, 170, 20);
  191.             ventanaSacar.getContentPane().add(textField_2sd);
  192.             textField_2sd.setColumns(10);
  193.        
  194.             JLabel SaldoActualsd = new JLabel("Saldo actual");
  195.             SaldoActualsd.setBounds(531, 166, 89, 14);
  196.             ventanaSacar.getContentPane().add(SaldoActualsd);
  197.        
  198.         // Constructor de ventana para Actualizar Saldo
  199.         ventanaActualizar = new JDialog(ventanaPrincipal, "Actualizar Saldo");
  200.         ventanaActualizar.setMinimumSize(new Dimension(800, 600));
  201.         ventanaActualizar.getContentPane().setLayout(null);
  202.        
  203.             JLabel lblNumeroDeCuentaas = new JLabel("N\u00FAmero de cuenta");
  204.             lblNumeroDeCuentaas.setBounds(94, 135, 110, 14);
  205.             ventanaActualizar.getContentPane().add(lblNumeroDeCuentaas);
  206.        
  207.             JTextField textFieldas = new JTextField();
  208.             textFieldas.setBounds(94, 188, 169, 20);
  209.             ventanaActualizar.getContentPane().add(textFieldas);
  210.             textFieldas.setColumns(10);
  211.        
  212.             JButton btnAplicarInteresas = new JButton("Aplicar Interes");
  213.             btnAplicarInteresas.setBounds(325, 155, 110, 23);
  214.             ventanaActualizar.getContentPane().add(btnAplicarInteresas);
  215.        
  216.             JLabel lblSaldoActualizadoas = new JLabel("Saldo actualizado");
  217.             lblSaldoActualizadoas.setBounds(491, 135, 102, 14);
  218.             ventanaActualizar.getContentPane().add(lblSaldoActualizadoas);
  219.        
  220.             JTextField textField_1as = new JTextField();
  221.             textField_1as.setEditable(false);
  222.             textField_1as.setBounds(491, 188, 169, 20);
  223.             ventanaActualizar.getContentPane().add(textField_1as);
  224.             textField_1as.setColumns(10);
  225.        
  226.  
  227.        
  228.            
  229.            
  230.            
  231.            
  232.         // ABRIR SECUNDARIAS Y CERRAR PRINCIPAL
  233.         boton1.addActionListener(new ActionListener() {
  234.             public void actionPerformed(ActionEvent e) {
  235.                 ventanaPrincipal.setVisible(false);
  236.                 ventanaCrear.setVisible(true);
  237.             }
  238.        
  239.         });
  240.         boton2.addActionListener(new ActionListener() {
  241.             public void actionPerformed(ActionEvent e) {
  242.                 ventanaPrincipal.setVisible(false);
  243.                 ventanaIngresar.setVisible(true);
  244.             }
  245.        
  246.         });
  247.         boton3.addActionListener(new ActionListener() {
  248.             public void actionPerformed(ActionEvent e) {
  249.                 ventanaPrincipal.setVisible(false);
  250.                 ventanaSacar.setVisible(true);
  251.             }
  252.        
  253.         });
  254.         boton4.addActionListener(new ActionListener() {
  255.             public void actionPerformed(ActionEvent e) {
  256.                 ventanaPrincipal.setVisible(false);
  257.                 ventanaActualizar.setVisible(true);
  258.             }
  259.        
  260.         });
  261.        
  262.         // CERRAR SECUNDARIAS Y ABRIR PRIMARIA
  263.         ventanaCrear.addWindowListener(new WindowAdapter() {
  264.             public void windowClosing(WindowEvent e) {
  265.                 ventanaPrincipal.setVisible(true);
  266.                 ventanaCrear.setVisible(false);
  267.             }
  268.        
  269.             public void windowClosed(WindowEvent e) {
  270.                 ventanaPrincipal.setVisible(true);
  271.                 ventanaCrear.setVisible(false);
  272.             }
  273.         });
  274.         ventanaIngresar.addWindowListener(new WindowAdapter() {
  275.             public void windowClosing(WindowEvent e) {
  276.                 ventanaPrincipal.setVisible(true);
  277.                 ventanaIngresar.setVisible(false);
  278.             }
  279.        
  280.             public void windowClosed(WindowEvent e) {
  281.                 ventanaPrincipal.setVisible(true);
  282.                 ventanaIngresar.setVisible(false);
  283.             }
  284.         });
  285.         ventanaSacar.addWindowListener(new WindowAdapter() {
  286.             public void windowClosing(WindowEvent e) {
  287.                 ventanaPrincipal.setVisible(true);
  288.                 ventanaSacar.setVisible(false);
  289.             }
  290.        
  291.             public void windowClosed(WindowEvent e) {
  292.                 ventanaPrincipal.setVisible(true);
  293.                 ventanaSacar.setVisible(false);
  294.             }
  295.         });
  296.         ventanaActualizar.addWindowListener(new WindowAdapter() {
  297.             public void windowClosing(WindowEvent e) {
  298.                 ventanaPrincipal.setVisible(true);
  299.                 ventanaActualizar.setVisible(false);
  300.             }
  301.        
  302.             public void windowClosed(WindowEvent e) {
  303.                 ventanaPrincipal.setVisible(true);
  304.                 ventanaActualizar.setVisible(false);
  305.             }
  306.         });
  307.        
  308.         // Mostrar la ventana principal
  309.         ventanaPrincipal.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  310.         ventanaPrincipal.setVisible(true);
  311.     }
  312.  
  313.  
  314.        
  315.     }
Add Comment
Please, Sign In to add comment