/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* AcercaDeNosotros.java
*
* Created on 05-jul-2010, 0:29:53
*/
package interfaz.alterna;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import modelo.utilidades.LugarEntrega;
import modelo.utilidades.ModeloComboBox;
import modelo.utilidades.ModeloTablaPaquete;
import modelo.utilidades.PaqueteEntrega;
/**
*
* @author Carlos
*/
public class RegistroPaquetes extends javax.swing.JDialog {
private ModeloComboBox modeloComboBoxBarrios;
private ModeloTablaPaquete modeloTablaPaquete;
/** Creates new form AcercaDeNosotros
* @param parent
* @param modal
* @param modeloComboBoxBarrios
* @param modeloTablaPaquete
*/
public RegistroPaquetes(java.awt.Frame parent, boolean modal, ModeloComboBox modeloComboBoxBarrios, ModeloTablaPaquete modeloTablaPaquete) {
super(parent, modal);
initComponents();
this.modeloComboBoxBarrios = modeloComboBoxBarrios;
modeloComboBoxBarrios.setSelectedItem("Seleccione");
jComboBoxBarrios.setModel(modeloComboBoxBarrios);
this.modeloTablaPaquete = modeloTablaPaquete;
}
public void setLookAndFeel(String LookAndFeel) {
if (LookAndFeel.equals("")) {
}
}
/** 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">//GEN-BEGIN:initComponents
private void initComponents() {
javax.swing.JLabel homepageLabel2 = new javax.swing.JLabel();
javax.swing.JLabel appHomepageLabel2 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
javax.swing.JLabel appTitleLabel = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
javax.swing.JLabel appDescLabel = new javax.swing.JLabel();
jComboBoxBarrios = new javax.swing.JComboBox();
javax.swing.JLabel appDescLabel1 = new javax.swing.JLabel();
jTextFieldNumPaquetes = new javax.swing.JTextField();
jPanel3 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
homepageLabel2.setFont(homepageLabel2.getFont().deriveFont(homepageLabel2.getFont().getStyle() | java.awt.Font.BOLD));
homepageLabel2.setText("- Herrera Valeria:");
homepageLabel2.setName("homepageLabel2"); // NOI18N
appHomepageLabel2.setText("lacyvaleria@yahoo.es");
appHomepageLabel2.setName("appHomepageLabel2"); // NOI18N
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Paquete");
jPanel1.setName("jPanel1"); // NOI18N
appTitleLabel.setFont(appTitleLabel.getFont().deriveFont(appTitleLabel.getFont().getStyle() | java.awt.Font.BOLD, appTitleLabel.getFont().getSize()+4));
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("internacionalizacion/Messages_es_EC"); // NOI18N
appTitleLabel.setText(bundle.getString("RegistroPaquetes_titulo")); // NOI18N
appTitleLabel.setName("appTitleLabel"); // NOI18N
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
jPanel2.setName("jPanel2"); // NOI18N
appDescLabel.setText(bundle.getString("RegistroPaquetes_lugarTuristico")); // NOI18N
appDescLabel.setName("appDescLabel"); // NOI18N
jComboBoxBarrios.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jComboBoxBarrios.setName("jComboBoxBarrios"); // NOI18N
jComboBoxBarrios.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBoxBarriosActionPerformed(evt);
}
});
appDescLabel1.setText(bundle.getString("RegistroPaquetes_numPaquetes")); // NOI18N
appDescLabel1.setName("appDescLabel1"); // NOI18N
jTextFieldNumPaquetes.setName("jTextFieldNumPaquetes"); // NOI18N
jTextFieldNumPaquetes.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldNumPaquetesActionPerformed(evt);
}
});
jTextFieldNumPaquetes.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
jTextFieldNumPaquetesKeyTyped(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(appDescLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
.addComponent(jTextFieldNumPaquetes, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(appDescLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(10, 10, 10)
.addComponent(jComboBoxBarrios, 0, 281, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jComboBoxBarrios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(appDescLabel))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(appDescLabel1)
.addComponent(jTextFieldNumPaquetes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel3.setName("jPanel3"); // NOI18N
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/save_download_32.png"))); // NOI18N
jButton1.setText("Guardar");
jButton1.setName("jButton1"); // NOI18N
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/newspaper_close_32.png"))); // NOI18N
jButton2.setText("Cancelar");
jButton2.setName("jButton2"); // NOI18N
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addContainerGap(68, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(34, 34, 34)
.addComponent(jButton2)
.addGap(70, 70, 70))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(119, 119, 119)
.addComponent(appTitleLabel))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(appTitleLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(79, 79, 79))
);
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(4, 4, 4)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
try {
if (this.jTextFieldNumPaquetes.getText() != null && Integer.parseInt(this.jTextFieldNumPaquetes.getText()) > 0) {
LugarEntrega lugarEntrega= (LugarEntrega) this.jComboBoxBarrios.getSelectedItem();
this.modeloTablaPaquete.addPaquetes(new PaqueteEntrega(lugarEntrega.getId(), lugarEntrega.getDenominacion(), Integer.parseInt(this.jTextFieldNumPaquetes.getText())));
this.modeloComboBoxBarrios.removeElementAt(this.jComboBoxBarrios.getSelectedIndex());
dispose();
} else {
JOptionPane.showMessageDialog(this, "Numero de paquetes incorrecto", "ERROR", JOptionPane.ERROR_MESSAGE);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Numero de paquetes incorrecto", "ERROR", JOptionPane.ERROR_MESSAGE);
}
}//GEN-LAST:event_jButton1ActionPerformed
private void jComboBoxBarriosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxBarriosActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jComboBoxBarriosActionPerformed
private void jTextFieldNumPaquetesKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldNumPaquetesKeyTyped
if (!Character.isDigit(evt.getKeyChar())) {
JOptionPane.showMessageDialog(this, "Por favor ingrese sólo números", "ALERTA", JOptionPane.ERROR_MESSAGE);
evt.consume();
}
if (evt.getKeyChar() == '.') {
JOptionPane.showMessageDialog(this, "Por favor ingrese sólo números", "ALERTA", JOptionPane.ERROR_MESSAGE);
}
}//GEN-LAST:event_jTextFieldNumPaquetesKeyTyped
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
dispose();
}//GEN-LAST:event_jButton2ActionPerformed
private void jTextFieldNumPaquetesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldNumPaquetesActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextFieldNumPaquetesActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JComboBox jComboBoxBarrios;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JTextField jTextFieldNumPaquetes;
// End of variables declaration//GEN-END:variables
}