Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package biblioteca;
- import javax.swing.DefaultComboBoxModel;
- import javax.swing.JOptionPane;
- /**
- *
- * @author Javier
- */
- public class VentanaSocio extends javax.swing.JFrame {
- /**
- * Creates new form VentanaSocio
- */
- Gestora gSocio = new Gestora();
- VentanaSocio vSocio = new VentanaSocio();
- // public void mostrarSocios() {
- // for (Socio unSocio : gSocio.getSocios()) {
- // JOptionPane.showMessageDialog(this, unSocio.toString());
- // }
- // }
- public VentanaSocio() {
- initComponents();
- jComboBoxRegion.setModel(new DefaultComboBoxModel(Region.values()));
- jComboBoxGenero.setModel(new DefaultComboBoxModel(Genero.values()));
- }
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jTextFieldCodigoSocio = new javax.swing.JTextField();
- jLabel2 = new javax.swing.JLabel();
- jTextFieldFechaNac = new javax.swing.JTextField();
- jLabel3 = new javax.swing.JLabel();
- jTextFieldNombre = new javax.swing.JTextField();
- jLabel4 = new javax.swing.JLabel();
- jComboBoxRegion = new javax.swing.JComboBox<>();
- jLabel5 = new javax.swing.JLabel();
- jTextFieldFechaAlta = new javax.swing.JTextField();
- jButtonCrear = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
- jLabel6 = new javax.swing.JLabel();
- jComboBoxGenero = new javax.swing.JComboBox<>();
- jButton3 = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
- setType(java.awt.Window.Type.UTILITY);
- jLabel1.setText("Código Socio");
- jLabel2.setText("Fecha Nacimiento");
- jLabel3.setText("Nombre");
- jLabel4.setText("Region");
- jLabel5.setText("Fecha Alta");
- jButtonCrear.setText("Añadir");
- jButtonCrear.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButtonCrearActionPerformed(evt);
- }
- });
- jButton2.setText("Cancelar");
- jLabel6.setText("Genero");
- jButton3.setText("Mostrar");
- jButton3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton3ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(45, 45, 45)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel2)
- .addComponent(jLabel3)
- .addComponent(jLabel4)
- .addComponent(jLabel5)
- .addComponent(jLabel1)
- .addComponent(jLabel6)
- .addComponent(jButtonCrear, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(30, 30, 30)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jComboBoxGenero, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(jTextFieldNombre)
- .addComponent(jTextFieldCodigoSocio)
- .addComponent(jTextFieldFechaNac)
- .addComponent(jComboBoxRegion, 0, 150, Short.MAX_VALUE)
- .addComponent(jTextFieldFechaAlta))))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
- .addComponent(jButton3))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jButton3))
- .addGroup(layout.createSequentialGroup()
- .addGap(44, 44, 44)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel3)
- .addComponent(jTextFieldNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(jTextFieldCodigoSocio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jTextFieldFechaNac, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel2))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel6)
- .addComponent(jComboBoxGenero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jComboBoxRegion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel4))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jTextFieldFechaAlta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel5))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(jButtonCrear, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE)
- .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
- .addContainerGap())
- );
- pack();
- }// </editor-fold>
- private void jButtonCrearActionPerformed(java.awt.event.ActionEvent evt) {
- gSocio.crearSocio(Integer.parseInt(jTextFieldCodigoSocio.getText()), jTextFieldFechaNac.getText(), jTextFieldNombre.getText(), jTextFieldFechaAlta.getText(), (Region) jComboBoxRegion.getSelectedItem(), (Genero) jComboBoxGenero.getSelectedItem());
- }
- private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
- for (Socio unSocio : gSocio.getSocios()) {
- JOptionPane.showMessageDialog(this, unSocio.toString());
- }
- // vSocio.mostrarSocios();
- }
- /**
- * @param args the command line arguments
- */
- // Variables declaration - do not modify
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JButton jButtonCrear;
- private javax.swing.JComboBox<String> jComboBoxGenero;
- private javax.swing.JComboBox<String> jComboBoxRegion;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabel5;
- private javax.swing.JLabel jLabel6;
- private javax.swing.JTextField jTextFieldCodigoSocio;
- private javax.swing.JTextField jTextFieldFechaAlta;
- private javax.swing.JTextField jTextFieldFechaNac;
- private javax.swing.JTextField jTextFieldNombre;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement