Advertisement
Guest User

VentanaSocio

a guest
Feb 23rd, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.41 KB | None | 0 0
  1. package biblioteca;
  2.  
  3. import javax.swing.DefaultComboBoxModel;
  4. import javax.swing.JOptionPane;
  5.  
  6. /**
  7.  *
  8.  * @author Javier
  9.  */
  10. public class VentanaSocio extends javax.swing.JFrame {
  11.  
  12.     /**
  13.      * Creates new form VentanaSocio
  14.      */
  15.     Gestora gSocio = new Gestora();
  16.     VentanaSocio vSocio = new VentanaSocio();
  17.  
  18. //    public void mostrarSocios() {
  19. //        for (Socio unSocio : gSocio.getSocios()) {
  20. //            JOptionPane.showMessageDialog(this, unSocio.toString());
  21. //        }
  22. //    }
  23.  
  24.     public VentanaSocio() {
  25.         initComponents();
  26.         jComboBoxRegion.setModel(new DefaultComboBoxModel(Region.values()));
  27.         jComboBoxGenero.setModel(new DefaultComboBoxModel(Genero.values()));
  28.     }
  29.  
  30.     /**
  31.      * This method is called from within the constructor to initialize the form.
  32.      * WARNING: Do NOT modify this code. The content of this method is always
  33.      * regenerated by the Form Editor.
  34.      */
  35.     @SuppressWarnings("unchecked")
  36.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  37.     private void initComponents() {
  38.  
  39.         jLabel1 = new javax.swing.JLabel();
  40.         jTextFieldCodigoSocio = new javax.swing.JTextField();
  41.         jLabel2 = new javax.swing.JLabel();
  42.         jTextFieldFechaNac = new javax.swing.JTextField();
  43.         jLabel3 = new javax.swing.JLabel();
  44.         jTextFieldNombre = new javax.swing.JTextField();
  45.         jLabel4 = new javax.swing.JLabel();
  46.         jComboBoxRegion = new javax.swing.JComboBox<>();
  47.         jLabel5 = new javax.swing.JLabel();
  48.         jTextFieldFechaAlta = new javax.swing.JTextField();
  49.         jButtonCrear = new javax.swing.JButton();
  50.         jButton2 = new javax.swing.JButton();
  51.         jLabel6 = new javax.swing.JLabel();
  52.         jComboBoxGenero = new javax.swing.JComboBox<>();
  53.         jButton3 = new javax.swing.JButton();
  54.  
  55.         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
  56.         setType(java.awt.Window.Type.UTILITY);
  57.  
  58.         jLabel1.setText("Código Socio");
  59.  
  60.         jLabel2.setText("Fecha Nacimiento");
  61.  
  62.         jLabel3.setText("Nombre");
  63.  
  64.         jLabel4.setText("Region");
  65.  
  66.         jLabel5.setText("Fecha Alta");
  67.  
  68.         jButtonCrear.setText("Añadir");
  69.         jButtonCrear.addActionListener(new java.awt.event.ActionListener() {
  70.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  71.                 jButtonCrearActionPerformed(evt);
  72.             }
  73.         });
  74.  
  75.         jButton2.setText("Cancelar");
  76.  
  77.         jLabel6.setText("Genero");
  78.  
  79.         jButton3.setText("Mostrar");
  80.         jButton3.addActionListener(new java.awt.event.ActionListener() {
  81.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  82.                 jButton3ActionPerformed(evt);
  83.             }
  84.         });
  85.  
  86.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  87.         getContentPane().setLayout(layout);
  88.         layout.setHorizontalGroup(
  89.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  90.             .addGroup(layout.createSequentialGroup()
  91.                 .addGap(45, 45, 45)
  92.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  93.                     .addComponent(jLabel2)
  94.                     .addComponent(jLabel3)
  95.                     .addComponent(jLabel4)
  96.                     .addComponent(jLabel5)
  97.                     .addComponent(jLabel1)
  98.                     .addComponent(jLabel6)
  99.                     .addComponent(jButtonCrear, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
  100.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  101.                     .addGroup(layout.createSequentialGroup()
  102.                         .addGap(30, 30, 30)
  103.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  104.                             .addComponent(jComboBoxGenero, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
  105.                             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  106.                                 .addComponent(jTextFieldNombre)
  107.                                 .addComponent(jTextFieldCodigoSocio)
  108.                                 .addComponent(jTextFieldFechaNac)
  109.                                 .addComponent(jComboBoxRegion, 0, 150, Short.MAX_VALUE)
  110.                                 .addComponent(jTextFieldFechaAlta))))
  111.                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  112.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  113.                         .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)))
  114.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
  115.                 .addComponent(jButton3))
  116.         );
  117.         layout.setVerticalGroup(
  118.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  119.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  120.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  121.                     .addGroup(layout.createSequentialGroup()
  122.                         .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  123.                         .addComponent(jButton3))
  124.                     .addGroup(layout.createSequentialGroup()
  125.                         .addGap(44, 44, 44)
  126.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  127.                             .addComponent(jLabel3)
  128.                             .addComponent(jTextFieldNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  129.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  130.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  131.                             .addComponent(jLabel1)
  132.                             .addComponent(jTextFieldCodigoSocio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  133.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  134.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  135.                             .addComponent(jTextFieldFechaNac, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  136.                             .addComponent(jLabel2))
  137.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  138.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  139.                             .addComponent(jLabel6)
  140.                             .addComponent(jComboBoxGenero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  141.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  142.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  143.                             .addComponent(jComboBoxRegion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  144.                             .addComponent(jLabel4))
  145.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  146.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  147.                             .addComponent(jTextFieldFechaAlta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  148.                             .addComponent(jLabel5))
  149.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
  150.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  151.                             .addComponent(jButtonCrear, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE)
  152.                             .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
  153.                 .addContainerGap())
  154.         );
  155.  
  156.         pack();
  157.     }// </editor-fold>                        
  158.  
  159.     private void jButtonCrearActionPerformed(java.awt.event.ActionEvent evt) {                                            
  160.         gSocio.crearSocio(Integer.parseInt(jTextFieldCodigoSocio.getText()), jTextFieldFechaNac.getText(), jTextFieldNombre.getText(), jTextFieldFechaAlta.getText(), (Region) jComboBoxRegion.getSelectedItem(), (Genero) jComboBoxGenero.getSelectedItem());
  161.     }                                            
  162.  
  163.     private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  164.         for (Socio unSocio : gSocio.getSocios()) {
  165.             JOptionPane.showMessageDialog(this, unSocio.toString());
  166.         }
  167. //        vSocio.mostrarSocios();
  168.     }                                        
  169.  
  170.     /**
  171.      * @param args the command line arguments
  172.      */
  173.  
  174.     // Variables declaration - do not modify                    
  175.     private javax.swing.JButton jButton2;
  176.     private javax.swing.JButton jButton3;
  177.     private javax.swing.JButton jButtonCrear;
  178.     private javax.swing.JComboBox<String> jComboBoxGenero;
  179.     private javax.swing.JComboBox<String> jComboBoxRegion;
  180.     private javax.swing.JLabel jLabel1;
  181.     private javax.swing.JLabel jLabel2;
  182.     private javax.swing.JLabel jLabel3;
  183.     private javax.swing.JLabel jLabel4;
  184.     private javax.swing.JLabel jLabel5;
  185.     private javax.swing.JLabel jLabel6;
  186.     private javax.swing.JTextField jTextFieldCodigoSocio;
  187.     private javax.swing.JTextField jTextFieldFechaAlta;
  188.     private javax.swing.JTextField jTextFieldFechaNac;
  189.     private javax.swing.JTextField jTextFieldNombre;
  190.     // End of variables declaration                  
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement