GreysitoErPutoAmo

JFrame Cuenta Bancaria

Mar 5th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.58 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.  
  6. import javax.swing.JButton;
  7. import javax.swing.JDialog;
  8. import javax.swing.JFrame;
  9. import javax.swing.JLabel;
  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.         JButton boton1 = new JButton("Crear Cuenta");
  35.         boton1.setBounds(156, 116, 483, 23);
  36.         JButton boton2 = new JButton("Ingresar Dinero");
  37.         boton2.setBounds(156, 315, 483, 23);
  38.         JButton boton3 = new JButton("Sacar Dinero");
  39.         boton3.setBounds(156, 349, 483, 23);
  40.         JButton boton4 = new JButton("Actualizar Saldo");
  41.         boton4.setBounds(156, 383, 483, 23);
  42.         ventanaPrincipal.getContentPane().setLayout(null);
  43.         ventanaPrincipal.getContentPane().add(boton1);
  44.         ventanaPrincipal.getContentPane().add(boton2);
  45.         ventanaPrincipal.getContentPane().add(boton3);
  46.         ventanaPrincipal.getContentPane().add(boton4);
  47.         ventanaPrincipal.pack();
  48.  
  49.        
  50.         // Construcción de ventana para Crear Cuenta
  51.         ventanaCrear = new JDialog(ventanaPrincipal,"Crear Cuenta");
  52.         ventanaCrear.setMinimumSize(new Dimension(800, 600));
  53.         ventanaCrear.getContentPane().setLayout(null);
  54.        
  55.         // Constructor de ventana para Ingresar Dinero
  56.         ventanaIngresar = new JDialog(ventanaPrincipal, "Ingresar Dinero");
  57.         ventanaIngresar.setMinimumSize(new Dimension(800, 600));
  58.        
  59.         // Constructor de ventana para Sacar Dinero
  60.         ventanaSacar = new JDialog(ventanaPrincipal, "Sacar Dinero");
  61.         ventanaSacar.setMinimumSize(new Dimension(800, 600));
  62.        
  63.         // Constructor de ventana para Actualizar Saldo
  64.         ventanaActualizar = new JDialog(ventanaPrincipal, "Actualizar Saldo");
  65.         ventanaActualizar.setMinimumSize(new Dimension(800, 600));
  66.        
  67.  
  68.         // ABRIR SECUNDARIAS Y CERRAR PRINCIPAL
  69.         boton1.addActionListener(new ActionListener() {
  70.             public void actionPerformed(ActionEvent e) {
  71.                 ventanaPrincipal.setVisible(false);
  72.                 ventanaCrear.setVisible(true);
  73.             }
  74.        
  75.         });
  76.         boton2.addActionListener(new ActionListener() {
  77.             public void actionPerformed(ActionEvent e) {
  78.                 ventanaPrincipal.setVisible(false);
  79.                 ventanaIngresar.setVisible(true);
  80.             }
  81.        
  82.         });
  83.         boton3.addActionListener(new ActionListener() {
  84.             public void actionPerformed(ActionEvent e) {
  85.                 ventanaPrincipal.setVisible(false);
  86.                 ventanaSacar.setVisible(true);
  87.             }
  88.        
  89.         });
  90.         boton4.addActionListener(new ActionListener() {
  91.             public void actionPerformed(ActionEvent e) {
  92.                 ventanaPrincipal.setVisible(false);
  93.                 ventanaActualizar.setVisible(true);
  94.             }
  95.        
  96.         });
  97.        
  98.         // CERRAR SECUNDARIAS Y ABRIR PRIMARIA
  99.         ventanaCrear.addWindowListener(new WindowAdapter() {
  100.             public void windowClosing(WindowEvent e) {
  101.                 ventanaPrincipal.setVisible(true);
  102.                 ventanaCrear.setVisible(false);
  103.             }
  104.        
  105.             public void windowClosed(WindowEvent e) {
  106.                 ventanaPrincipal.setVisible(true);
  107.                 ventanaCrear.setVisible(false);
  108.             }
  109.         });
  110.         ventanaIngresar.addWindowListener(new WindowAdapter() {
  111.             public void windowClosing(WindowEvent e) {
  112.                 ventanaPrincipal.setVisible(true);
  113.                 ventanaIngresar.setVisible(false);
  114.             }
  115.        
  116.             public void windowClosed(WindowEvent e) {
  117.                 ventanaPrincipal.setVisible(true);
  118.                 ventanaIngresar.setVisible(false);
  119.             }
  120.         });
  121.         ventanaSacar.addWindowListener(new WindowAdapter() {
  122.             public void windowClosing(WindowEvent e) {
  123.                 ventanaPrincipal.setVisible(true);
  124.                 ventanaSacar.setVisible(false);
  125.             }
  126.        
  127.             public void windowClosed(WindowEvent e) {
  128.                 ventanaPrincipal.setVisible(true);
  129.                 ventanaSacar.setVisible(false);
  130.             }
  131.         });
  132.         ventanaActualizar.addWindowListener(new WindowAdapter() {
  133.             public void windowClosing(WindowEvent e) {
  134.                 ventanaPrincipal.setVisible(true);
  135.                 ventanaActualizar.setVisible(false);
  136.             }
  137.        
  138.             public void windowClosed(WindowEvent e) {
  139.                 ventanaPrincipal.setVisible(true);
  140.                 ventanaActualizar.setVisible(false);
  141.             }
  142.         });
  143.        
  144.         // Mostrar la ventana principal
  145.         ventanaPrincipal.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  146.         ventanaPrincipal.setVisible(true);
  147.     }
  148.  
  149.  
  150.        
  151.     }
Add Comment
Please, Sign In to add comment