Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.WindowAdapter;
- import java.awt.event.WindowEvent;
- import javax.swing.JButton;
- import javax.swing.JDialog;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.WindowConstants;
- import java.awt.Dimension;
- public class jframecb {
- private JFrame ventanaPrincipal;
- private JDialog ventanaCrear;
- private JDialog ventanaIngresar;
- private JDialog ventanaSacar;
- private JDialog ventanaActualizar;
- /**
- * @param args
- */
- public static void main(String[] args) {
- new jframecb();
- }
- public jframecb()
- {
- // Construcción de ventana principal
- ventanaPrincipal = new JFrame("Ventana principal");
- ventanaPrincipal.setMinimumSize(new Dimension(800, 600));
- ventanaPrincipal.setAutoRequestFocus(false);
- ventanaPrincipal.setResizable(false);
- JButton boton1 = new JButton("Crear Cuenta");
- boton1.setBounds(156, 116, 483, 23);
- JButton boton2 = new JButton("Ingresar Dinero");
- boton2.setBounds(156, 315, 483, 23);
- JButton boton3 = new JButton("Sacar Dinero");
- boton3.setBounds(156, 349, 483, 23);
- JButton boton4 = new JButton("Actualizar Saldo");
- boton4.setBounds(156, 383, 483, 23);
- ventanaPrincipal.getContentPane().setLayout(null);
- ventanaPrincipal.getContentPane().add(boton1);
- ventanaPrincipal.getContentPane().add(boton2);
- ventanaPrincipal.getContentPane().add(boton3);
- ventanaPrincipal.getContentPane().add(boton4);
- ventanaPrincipal.pack();
- // Construcción de ventana para Crear Cuenta
- ventanaCrear = new JDialog(ventanaPrincipal,"Crear Cuenta");
- ventanaCrear.setMinimumSize(new Dimension(800, 600));
- ventanaCrear.getContentPane().setLayout(null);
- // Constructor de ventana para Ingresar Dinero
- ventanaIngresar = new JDialog(ventanaPrincipal, "Ingresar Dinero");
- ventanaIngresar.setMinimumSize(new Dimension(800, 600));
- // Constructor de ventana para Sacar Dinero
- ventanaSacar = new JDialog(ventanaPrincipal, "Sacar Dinero");
- ventanaSacar.setMinimumSize(new Dimension(800, 600));
- // Constructor de ventana para Actualizar Saldo
- ventanaActualizar = new JDialog(ventanaPrincipal, "Actualizar Saldo");
- ventanaActualizar.setMinimumSize(new Dimension(800, 600));
- // ABRIR SECUNDARIAS Y CERRAR PRINCIPAL
- boton1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- ventanaPrincipal.setVisible(false);
- ventanaCrear.setVisible(true);
- }
- });
- boton2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- ventanaPrincipal.setVisible(false);
- ventanaIngresar.setVisible(true);
- }
- });
- boton3.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- ventanaPrincipal.setVisible(false);
- ventanaSacar.setVisible(true);
- }
- });
- boton4.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- ventanaPrincipal.setVisible(false);
- ventanaActualizar.setVisible(true);
- }
- });
- // CERRAR SECUNDARIAS Y ABRIR PRIMARIA
- ventanaCrear.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- ventanaPrincipal.setVisible(true);
- ventanaCrear.setVisible(false);
- }
- public void windowClosed(WindowEvent e) {
- ventanaPrincipal.setVisible(true);
- ventanaCrear.setVisible(false);
- }
- });
- ventanaIngresar.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- ventanaPrincipal.setVisible(true);
- ventanaIngresar.setVisible(false);
- }
- public void windowClosed(WindowEvent e) {
- ventanaPrincipal.setVisible(true);
- ventanaIngresar.setVisible(false);
- }
- });
- ventanaSacar.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- ventanaPrincipal.setVisible(true);
- ventanaSacar.setVisible(false);
- }
- public void windowClosed(WindowEvent e) {
- ventanaPrincipal.setVisible(true);
- ventanaSacar.setVisible(false);
- }
- });
- ventanaActualizar.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- ventanaPrincipal.setVisible(true);
- ventanaActualizar.setVisible(false);
- }
- public void windowClosed(WindowEvent e) {
- ventanaPrincipal.setVisible(true);
- ventanaActualizar.setVisible(false);
- }
- });
- // Mostrar la ventana principal
- ventanaPrincipal.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- ventanaPrincipal.setVisible(true);
- }
- }
Add Comment
Please, Sign In to add comment