daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Nov 5th, 2018 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package principal;
  7.  
  8. /**
  9.  *
  10.  * @author Ale
  11.  */
  12. public class Ventana1 extends javax.swing.JFrame {
  13.     Operaciones ver;
  14.  
  15.  
  16.     /**
  17.      * Creates new form Ventana1
  18.      */
  19.     public Ventana1() {
  20.         ver = new Operaciones();
  21.  
  22.         initComponents();
  23.     }
  24.  
  25.     /**
  26.      * This method is called from within the constructor to initialize the form.
  27.      * WARNING: Do NOT modify this code. The content of this method is always
  28.      * regenerated by the Form Editor.
  29.      */
  30.     @SuppressWarnings("unchecked")
  31.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  32.     private void initComponents() {
  33.  
  34.         jPanel1 = new javax.swing.JPanel();
  35.         jPanel2 = new javax.swing.JPanel();
  36.         jLabel1 = new javax.swing.JLabel();
  37.         campo_edad = new javax.swing.JTextField();
  38.         btn_verificarmayoria = new javax.swing.JButton();
  39.         jLabel2 = new javax.swing.JLabel();
  40.         campo_mayor_o_menor = new javax.swing.JTextField();
  41.         jPanel3 = new javax.swing.JPanel();
  42.         jLabel3 = new javax.swing.JLabel();
  43.         campo_dia = new javax.swing.JTextField();
  44.         btn_verificar_dia = new javax.swing.JButton();
  45.         campo_res_dia = new javax.swing.JTextField();
  46.         jLabel4 = new javax.swing.JLabel();
  47.         jPanel4 = new javax.swing.JPanel();
  48.         jLabel5 = new javax.swing.JLabel();
  49.         campo_num1 = new javax.swing.JTextField();
  50.         jLabel6 = new javax.swing.JLabel();
  51.         campo_num2 = new javax.swing.JTextField();
  52.         jLabel7 = new javax.swing.JLabel();
  53.         campo_opcion = new javax.swing.JTextField();
  54.         btn_calcular = new javax.swing.JButton();
  55.         jLabel8 = new javax.swing.JLabel();
  56.         campo_total = new javax.swing.JTextField();
  57.         jPanel5 = new javax.swing.JPanel();
  58.         jLabel9 = new javax.swing.JLabel();
  59.         campo_usuario = new javax.swing.JTextField();
  60.         jLabel10 = new javax.swing.JLabel();
  61.         campo_contrasena = new javax.swing.JTextField();
  62.         btn_ingresar = new javax.swing.JButton();
  63.  
  64.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  65.  
  66.         jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Ejercicio1"));
  67.  
  68.         jLabel1.setText("Ingrese edad");
  69.  
  70.         btn_verificarmayoria.setText("Verificar mayoria de edad");
  71.         btn_verificarmayoria.addActionListener(new java.awt.event.ActionListener() {
  72.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  73.                 btn_verificarmayoriaActionPerformed(evt);
  74.             }
  75.         });
  76.  
  77.         jLabel2.setText("Resultado");
  78.  
  79.         javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
  80.         jPanel2.setLayout(jPanel2Layout);
  81.         jPanel2Layout.setHorizontalGroup(
  82.             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  83.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
  84.                 .addContainerGap()
  85.                 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  86.                     .addComponent(campo_mayor_o_menor)
  87.                     .addComponent(btn_verificarmayoria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  88.                     .addComponent(campo_edad, javax.swing.GroupLayout.Alignment.LEADING)
  89.                     .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
  90.                         .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  91.                             .addComponent(jLabel1)
  92.                             .addComponent(jLabel2))
  93.                         .addGap(0, 0, Short.MAX_VALUE)))
  94.                 .addContainerGap())
  95.         );
  96.         jPanel2Layout.setVerticalGroup(
  97.             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  98.             .addGroup(jPanel2Layout.createSequentialGroup()
  99.                 .addContainerGap()
  100.                 .addComponent(jLabel1)
  101.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  102.                 .addComponent(campo_edad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  103.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  104.                 .addComponent(btn_verificarmayoria)
  105.                 .addGap(56, 56, 56)
  106.                 .addComponent(jLabel2)
  107.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  108.                 .addComponent(campo_mayor_o_menor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  109.                 .addContainerGap(62, Short.MAX_VALUE))
  110.         );
  111.  
  112.         jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Ejercicio2"));
  113.  
  114.         jLabel3.setText("Ingrese numero de dia:");
  115.  
  116.         btn_verificar_dia.setText("Verficar dia");
  117.         btn_verificar_dia.addActionListener(new java.awt.event.ActionListener() {
  118.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  119.                 btn_verificar_diaActionPerformed(evt);
  120.             }
  121.         });
  122.  
  123.         campo_res_dia.addActionListener(new java.awt.event.ActionListener() {
  124.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  125.                 campo_res_diaActionPerformed(evt);
  126.             }
  127.         });
  128.  
  129.         jLabel4.setText("Resultado");
  130.  
  131.         javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
  132.         jPanel3.setLayout(jPanel3Layout);
  133.         jPanel3Layout.setHorizontalGroup(
  134.             jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  135.             .addGroup(jPanel3Layout.createSequentialGroup()
  136.                 .addContainerGap()
  137.                 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  138.                     .addComponent(btn_verificar_dia, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  139.                     .addComponent(campo_dia)
  140.                     .addComponent(campo_res_dia)
  141.                     .addGroup(jPanel3Layout.createSequentialGroup()
  142.                         .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  143.                             .addComponent(jLabel3)
  144.                             .addComponent(jLabel4))
  145.                         .addGap(0, 363, Short.MAX_VALUE)))
  146.                 .addContainerGap())
  147.         );
  148.         jPanel3Layout.setVerticalGroup(
  149.             jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  150.             .addGroup(jPanel3Layout.createSequentialGroup()
  151.                 .addContainerGap()
  152.                 .addComponent(jLabel3)
  153.                 .addGap(18, 18, 18)
  154.                 .addComponent(campo_dia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  155.                 .addGap(18, 18, 18)
  156.                 .addComponent(btn_verificar_dia)
  157.                 .addGap(33, 33, 33)
  158.                 .addComponent(jLabel4)
  159.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  160.                 .addComponent(campo_res_dia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  161.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  162.         );
  163.  
  164.         jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Ejercicio3"));
  165.  
  166.         jLabel5.setText("Ingrese numero 1:");
  167.  
  168.         jLabel6.setText("Ingrese numero 2:");
  169.  
  170.         jLabel7.setText("Opcion 1) Suma 2)Restar 3)Multiplicar 4)Dividir");
  171.  
  172.         btn_calcular.setText("Calcular");
  173.         btn_calcular.addActionListener(new java.awt.event.ActionListener() {
  174.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  175.                 btn_calcularActionPerformed(evt);
  176.             }
  177.         });
  178.  
  179.         jLabel8.setText("Resultado");
  180.  
  181.         javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
  182.         jPanel4.setLayout(jPanel4Layout);
  183.         jPanel4Layout.setHorizontalGroup(
  184.             jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  185.             .addGroup(jPanel4Layout.createSequentialGroup()
  186.                 .addContainerGap()
  187.                 .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  188.                     .addComponent(jLabel5)
  189.                     .addComponent(jLabel6)
  190.                     .addComponent(jLabel7)
  191.                     .addComponent(campo_opcion)
  192.                     .addComponent(campo_num1)
  193.                     .addComponent(campo_num2)
  194.                     .addComponent(btn_calcular, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
  195.                     .addComponent(jLabel8)
  196.                     .addComponent(campo_total))
  197.                 .addContainerGap(17, Short.MAX_VALUE))
  198.         );
  199.         jPanel4Layout.setVerticalGroup(
  200.             jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  201.             .addGroup(jPanel4Layout.createSequentialGroup()
  202.                 .addGap(24, 24, 24)
  203.                 .addComponent(jLabel5)
  204.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  205.                 .addComponent(campo_num1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  206.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  207.                 .addComponent(jLabel6)
  208.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  209.                 .addComponent(campo_num2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  210.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  211.                 .addComponent(jLabel7)
  212.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  213.                 .addComponent(campo_opcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  214.                 .addGap(18, 18, 18)
  215.                 .addComponent(btn_calcular)
  216.                 .addGap(63, 63, 63)
  217.                 .addComponent(jLabel8)
  218.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  219.                 .addComponent(campo_total, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  220.                 .addContainerGap(51, Short.MAX_VALUE))
  221.         );
  222.  
  223.         jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Ejercicio4"));
  224.  
  225.         jLabel9.setText("Ingrese usuario:");
  226.  
  227.         jLabel10.setText("Ingrese ContraseƱa:");
  228.  
  229.         btn_ingresar.setText("Ingresar");
  230.         btn_ingresar.addActionListener(new java.awt.event.ActionListener() {
  231.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  232.                 btn_ingresarActionPerformed(evt);
  233.             }
  234.         });
  235.  
  236.         javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
  237.         jPanel5.setLayout(jPanel5Layout);
  238.         jPanel5Layout.setHorizontalGroup(
  239.             jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  240.             .addGroup(jPanel5Layout.createSequentialGroup()
  241.                 .addContainerGap()
  242.                 .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  243.                     .addComponent(campo_usuario)
  244.                     .addComponent(campo_contrasena)
  245.                     .addGroup(jPanel5Layout.createSequentialGroup()
  246.                         .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  247.                             .addComponent(jLabel9)
  248.                             .addComponent(jLabel10))
  249.                         .addGap(0, 0, Short.MAX_VALUE))
  250.                     .addComponent(btn_ingresar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  251.                 .addContainerGap())
  252.         );
  253.         jPanel5Layout.setVerticalGroup(
  254.             jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  255.             .addGroup(jPanel5Layout.createSequentialGroup()
  256.                 .addGap(44, 44, 44)
  257.                 .addComponent(jLabel9)
  258.                 .addGap(18, 18, 18)
  259.                 .addComponent(campo_usuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  260.                 .addGap(18, 18, 18)
  261.                 .addComponent(jLabel10)
  262.                 .addGap(18, 18, 18)
  263.                 .addComponent(campo_contrasena, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  264.                 .addGap(50, 50, 50)
  265.                 .addComponent(btn_ingresar)
  266.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  267.         );
  268.  
  269.         javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  270.         jPanel1.setLayout(jPanel1Layout);
  271.         jPanel1Layout.setHorizontalGroup(
  272.             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  273.             .addGroup(jPanel1Layout.createSequentialGroup()
  274.                 .addContainerGap()
  275.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  276.                     .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  277.                     .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  278.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  279.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  280.                     .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  281.                     .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  282.                 .addContainerGap())
  283.         );
  284.         jPanel1Layout.setVerticalGroup(
  285.             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  286.             .addGroup(jPanel1Layout.createSequentialGroup()
  287.                 .addContainerGap()
  288.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  289.                     .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  290.                     .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  291.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  292.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  293.                     .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  294.                     .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  295.                 .addContainerGap())
  296.         );
  297.  
  298.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  299.         getContentPane().setLayout(layout);
  300.         layout.setHorizontalGroup(
  301.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  302.             .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  303.         );
  304.         layout.setVerticalGroup(
  305.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  306.             .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  307.         );
  308.  
  309.         pack();
  310.     }// </editor-fold>                        
  311.  
  312.     private void campo_res_diaActionPerformed(java.awt.event.ActionEvent evt) {                                              
  313.         // TODO add your handling code here:
  314.     }                                            
  315.  
  316.     private void btn_verificarmayoriaActionPerformed(java.awt.event.ActionEvent evt) {                                                    
  317.         int edad = Integer.parseInt(campo_edad.getText());
  318.         ver.ejercicio1(edad,campo_mayor_o_menor);
  319.     }                                                    
  320.  
  321.     private void btn_verificar_diaActionPerformed(java.awt.event.ActionEvent evt) {                                                  
  322.         int dia =Integer.parseInt(campo_dia.getText());
  323.         ver.ejercicio2(dia,campo_res_dia);
  324.     }                                                
  325.  
  326.     private void btn_calcularActionPerformed(java.awt.event.ActionEvent evt) {                                            
  327.         int num1=Integer.parseInt(campo_num1.getText());
  328.         int num2=Integer.parseInt(campo_num2.getText());
  329.         int opcion=Integer.parseInt(campo_opcion.getText());
  330.         ver.ejercicio3(num1,num2,opcion,campo_total);
  331.     }                                            
  332.  
  333.     private void btn_ingresarActionPerformed(java.awt.event.ActionEvent evt) {                                            
  334.         String usuario=campo_usuario.getText();
  335.         String contrasena =campo_contrasena.getText();
  336.         ver.ejercicio4(usuario, contrasena);
  337.  
  338.     }                                            
  339.  
  340.     /**
  341.      * @param args the command line arguments
  342.      */
  343.     public static void main(String args[]) {
  344.         /* Set the Nimbus look and feel */
  345.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  346.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  347.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  348.          */
  349.         try {
  350.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  351.                 if ("Nimbus".equals(info.getName())) {
  352.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  353.                     break;
  354.                 }
  355.             }
  356.         } catch (ClassNotFoundException ex) {
  357.             java.util.logging.Logger.getLogger(Ventana1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  358.         } catch (InstantiationException ex) {
  359.             java.util.logging.Logger.getLogger(Ventana1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  360.         } catch (IllegalAccessException ex) {
  361.             java.util.logging.Logger.getLogger(Ventana1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  362.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  363.             java.util.logging.Logger.getLogger(Ventana1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  364.         }
  365.         //</editor-fold>
  366.  
  367.         /* Create and display the form */
  368.         java.awt.EventQueue.invokeLater(new Runnable() {
  369.             public void run() {
  370.                 new Ventana1().setVisible(true);
  371.             }
  372.         });
  373.     }
  374.  
  375.     // Variables declaration - do not modify                    
  376.     private javax.swing.JButton btn_calcular;
  377.     private javax.swing.JButton btn_ingresar;
  378.     private javax.swing.JButton btn_verificar_dia;
  379.     private javax.swing.JButton btn_verificarmayoria;
  380.     private javax.swing.JTextField campo_contrasena;
  381.     private javax.swing.JTextField campo_dia;
  382.     private javax.swing.JTextField campo_edad;
  383.     private javax.swing.JTextField campo_mayor_o_menor;
  384.     private javax.swing.JTextField campo_num1;
  385.     private javax.swing.JTextField campo_num2;
  386.     private javax.swing.JTextField campo_opcion;
  387.     private javax.swing.JTextField campo_res_dia;
  388.     private javax.swing.JTextField campo_total;
  389.     private javax.swing.JTextField campo_usuario;
  390.     private javax.swing.JLabel jLabel1;
  391.     private javax.swing.JLabel jLabel10;
  392.     private javax.swing.JLabel jLabel2;
  393.     private javax.swing.JLabel jLabel3;
  394.     private javax.swing.JLabel jLabel4;
  395.     private javax.swing.JLabel jLabel5;
  396.     private javax.swing.JLabel jLabel6;
  397.     private javax.swing.JLabel jLabel7;
  398.     private javax.swing.JLabel jLabel8;
  399.     private javax.swing.JLabel jLabel9;
  400.     private javax.swing.JPanel jPanel1;
  401.     private javax.swing.JPanel jPanel2;
  402.     private javax.swing.JPanel jPanel3;
  403.     private javax.swing.JPanel jPanel4;
  404.     private javax.swing.JPanel jPanel5;
  405.     // End of variables declaration                  
  406. }
  407.  
  408.  
  409. /*
  410.  * To change this license header, choose License Headers in Project Properties.
  411.  * To change this template file, choose Tools | Templates
  412.  * and open the template in the editor.
  413.  */
  414. package principal;
  415.  
  416. import javax.swing.JOptionPane;
  417. import javax.swing.JTextField;
  418.  
  419.  
  420. /**
  421.  *
  422.  * @author Ale
  423.  */
  424. public class Operaciones {
  425.     Ventana_desplegable ven2;
  426.     public void ejercicio1(int edad, JTextField campo_edad_may_o_men){
  427.         if (edad>=18){
  428.             campo_edad_may_o_men.setText("Es mayor de edad");            
  429.         }else{
  430.             campo_edad_may_o_men.setText("Es menor de edad");
  431.         }
  432.    
  433.     }
  434.    
  435.     public void ejercicio2(int dia, JTextField campo_resultado_dia){
  436.         switch(dia){
  437.             case 1:
  438.                 campo_resultado_dia.setText("Lunes");
  439.                 break;
  440.            
  441.             case 2:
  442.                 campo_resultado_dia.setText("Martes");
  443.                 break;
  444.                
  445.             case 3:
  446.                 campo_resultado_dia.setText("Miercoles");
  447.                 break;
  448.            
  449.             case 4:
  450.                 campo_resultado_dia.setText("Jueves");
  451.                 break;
  452.                
  453.             case 5:
  454.                 campo_resultado_dia.setText("Viernes");
  455.                 break;
  456.                
  457.             case 6:
  458.                 campo_resultado_dia.setText("Sabado");
  459.                 break;
  460.            
  461.             case 7:
  462.                 campo_resultado_dia.setText("Domingo");
  463.                 break;
  464.            
  465.             default:
  466.                 campo_resultado_dia.setText("Ingrese dia correcto 1 a 7");
  467.                 break;
  468.         }
  469.            
  470.     }
  471.  
  472.     public void ejercicio3(int num1, int num2, int opcion, JTextField campo_resultado_op){
  473.         switch(opcion){
  474.             case 1:
  475.                 int suma=(num1+num2);
  476.                 campo_resultado_op.setText("Resultado: "+suma);
  477.                 break;
  478.             case 2:
  479.                 int resta=(num1-num2);
  480.                 campo_resultado_op.setText("Resultado: "+resta);
  481.                 break;
  482.             case 3:
  483.                 int multiplicacion=(num1*num2);
  484.                 campo_resultado_op.setText("Resultado: "+multiplicacion);
  485.                 break;
  486.             case 4:
  487.                 if(num2!=0){
  488.                     int division=num1/num2;
  489.                     campo_resultado_op.setText("Resultado: "+ division);
  490.                     break;
  491.                 }else{
  492.                     campo_resultado_op.setText("Ingrese segundo numero distinto de 0...");
  493.                 }
  494.                 break;
  495.             default:
  496.                 campo_resultado_op.setText("Ingrese opcion de 1 a 4...");
  497.                 break;
  498.                
  499.         }
  500.    
  501.  
  502.     }
  503.  
  504.      public void ejercicio4(String usuario,String contrasena){      
  505.         String user="aleh";
  506.         String pass="ale1234";
  507.         ven2= new Ventana_desplegable();
  508.        
  509.         if(usuario.equals(user) && contrasena.equals(pass)){
  510.             JOptionPane.showMessageDialog(null,"Bienvenido");
  511.                 ven2.setVisible(true);
  512.         }else{
  513.             JOptionPane.showMessageDialog(null,"Usuario y/o contraseƱa incorrecto/s");
  514.         }
  515.        
  516.     }
  517. }    
  518.  
  519. /*
  520.  * To change this license header, choose License Headers in Project Properties.
  521.  * To change this template file, choose Tools | Templates
  522.  * and open the template in the editor.
  523.  */
  524. package principal;
  525.  
  526. /**
  527.  *
  528.  * @author Ale
  529.  */
  530. public class Ventana_desplegable extends javax.swing.JFrame {
  531.  
  532.     /**
  533.      * Creates new form Ventana_desplegable
  534.      */
  535.     public void Ventana_desplegable() {
  536.         initComponents();
  537.     }
  538.  
  539.     /**
  540.      * This method is called from within the constructor to initialize the form.
  541.      * WARNING: Do NOT modify this code. The content of this method is always
  542.      * regenerated by the Form Editor.
  543.      */
  544.     @SuppressWarnings("unchecked")
  545.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  546.     private void initComponents() {
  547.  
  548.         jPanel2 = new javax.swing.JPanel();
  549.         jTextField2 = new javax.swing.JTextField();
  550.  
  551.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  552.  
  553.         jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("ventana desplegable"));
  554.  
  555.         jTextField2.setText("jTextField2");
  556.  
  557.         javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
  558.         jPanel2.setLayout(jPanel2Layout);
  559.         jPanel2Layout.setHorizontalGroup(
  560.             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  561.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
  562.                 .addContainerGap()
  563.                 .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)
  564.                 .addContainerGap())
  565.         );
  566.         jPanel2Layout.setVerticalGroup(
  567.             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  568.             .addGroup(jPanel2Layout.createSequentialGroup()
  569.                 .addGap(181, 181, 181)
  570.                 .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  571.                 .addContainerGap(202, Short.MAX_VALUE))
  572.         );
  573.  
  574.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  575.         getContentPane().setLayout(layout);
  576.         layout.setHorizontalGroup(
  577.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  578.             .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  579.         );
  580.         layout.setVerticalGroup(
  581.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  582.             .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  583.         );
  584.  
  585.         pack();
  586.     }// </editor-fold>                        
  587.  
  588.     /**
  589.      * @param args the command line arguments
  590.      */
  591.     public static void main(String args[]) {
  592.         /* Set the Nimbus look and feel */
  593.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  594.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  595.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  596.          */
  597.         try {
  598.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  599.                 if ("Nimbus".equals(info.getName())) {
  600.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  601.                     break;
  602.                 }
  603.             }
  604.         } catch (ClassNotFoundException ex) {
  605.             java.util.logging.Logger.getLogger(Ventana_desplegable.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  606.         } catch (InstantiationException ex) {
  607.             java.util.logging.Logger.getLogger(Ventana_desplegable.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  608.         } catch (IllegalAccessException ex) {
  609.             java.util.logging.Logger.getLogger(Ventana_desplegable.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  610.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  611.             java.util.logging.Logger.getLogger(Ventana_desplegable.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  612.         }
  613.         //</editor-fold>
  614.  
  615.         /* Create and display the form */
  616.         java.awt.EventQueue.invokeLater(new Runnable() {
  617.             public void run() {
  618.                 new Ventana_desplegable().setVisible(true);
  619.             }
  620.         });
  621.     }
  622.  
  623.     // Variables declaration - do not modify                    
  624.     private javax.swing.JPanel jPanel2;
  625.     private javax.swing.JTextField jTextField2;
  626.     // End of variables declaration                  
  627.  
  628.    
  629.  
  630. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top