RE:Problema evento en JComboBox
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jbBuscar = new javax.swing.JButton();
jbCancelar = new javax.swing.JButton();
jlCantones = new javax.swing.JLabel();
jcbCantones = new javax.swing.JComboBox();
jlNombreDistrito = new javax.swing.JLabel();
jcbDistritos = new javax.swing.JComboBox();
jlProvincia = new javax.swing.JLabel();
jcbProvincias = new javax.swing.JComboBox();
setTitle("Buscar un Distrito");
jPanel1.setBackground(new java.awt.Color(0, 0, 0));
jPanel2.setBackground(new java.awt.Color(0, 0, 0));
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)), "Seleccione el Distrito a Modificar", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), new java.awt.Color(255, 255, 255))); // NOI18N
jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jbBuscar.setText("Buscar");
jbBuscar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbBuscarActionPerformed(evt);
}
});
jPanel2.add(jbBuscar, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 150, 80, -1));
jbCancelar.setText("Cancelar");
jbCancelar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbCancelarActionPerformed(evt);
}
});
jPanel2.add(jbCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 150, -1, -1));
jlCantones.setForeground(new java.awt.Color(255, 255, 255));
jlCantones.setText("Canton:");
jPanel2.add(jlCantones, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, -1, -1));
jPanel2.add(jcbCantones, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 70, 123, -1));
jlNombreDistrito.setForeground(new java.awt.Color(255, 255, 255));
jlNombreDistrito.setText("Distrito:");
jPanel2.add(jlNombreDistrito, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 110, -1, -1));
jPanel2.add(jcbDistritos, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 110, 123, -1));
jlProvincia.setForeground(new java.awt.Color(255, 255, 255));
jlProvincia.setText("Provincia:");
jPanel2.add(jlProvincia, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, -1, -1));
jPanel2.add(jcbProvincias, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 30, 123, -1));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 280, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(11, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(15, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void jbBuscarActionPerformed(java.awt.event.ActionEvent evt) {
if((jcbDistritos.getSelectedItem() == null) == false){
DistritoBean distritoBean = new DistritoBean();
distritoBean.setNombreDistrito(jcbDistritos.getSelectedItem().toString());
DistritoBusiness distritoBusiness = new DistritoBusiness(conexion);
DistritoBean distritoBeanResultado = new DistritoBean();
try {
distritoBeanResultado = distritoBusiness.getDistritoPorNombre(distritoBean);
FrameModificarDistrito modificarDistrito = new FrameModificarDistrito(conexion, distritoBeanResultado,parent);
modificarDistrito.setClosable(true);
parent.add(modificarDistrito);
parent.centrarInternal(modificarDistrito);
modificarDistrito.setVisible(true);
String mensaje = "Se efectúo una búsqueda de un Distrito con nombre " + distritoBeanResultado.getNombreDistrito() + " en la Base de Datos";
String filtroAuditoria = "Otros";
parent.auditoria(mensaje, filtroAuditoria);
this.dispose();
} catch (SQLException ex) {
JOptionPane.showMessageDialog(this, "Error de Base de Datos", "Error", 0);
}
}else{
JOptionPane.showMessageDialog(this, "Actualmente no se encuentra seleccionado ningún Distrito, verifique e intente de nuevo.", "Información", 2);
}
}
private void jbCancelarActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
}
// Variables declaration - do not modify
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JButton jbBuscar;
private javax.swing.JButton jbCancelar;
private javax.swing.JComboBox jcbCantones;
private javax.swing.JComboBox jcbDistritos;
private javax.swing.JComboBox jcbProvincias;
private javax.swing.JLabel jlCantones;
private javax.swing.JLabel jlNombreDistrito;
private javax.swing.JLabel jlProvincia;
// End of variables declaration
}