borrado de elementos de un jlist
Hola
Tengo el siguiente problema con 2 objetos jlist, los cuales trato de mover sus elementos de un lado a otro pero al hacer el borrado me manda lo siguiente excepcion
17:08:13,625 [INFO] (MessageArrived.java\:863) - ==> Mensaje RespuestaBanksDenyConf: 200
17:08:14,718 [INFO] (frmBloqueoInstituciones.java\:503) - <<== quitaInstitucionesPorDesBloquear cuantos tiene:9 indices:9
17:08:14,718 [INFO] (frmBloqueoInstituciones.java\:507) - objeto:40 posicion:0
17:08:14,744 [INFO] (frmBloqueoInstituciones.java\:507) - objeto:41 posicion:1
17:08:14,769 [INFO] (frmBloqueoInstituciones.java\:507) - objeto:42 posicion:2
17:08:14,796 [INFO] (frmBloqueoInstituciones.java\:507) - objeto:43 posicion:3
17:08:14,821 [INFO] (frmBloqueoInstituciones.java\:507) - objeto:44 posicion:4
17:08:14,846 [INFO] (frmBloqueoInstituciones.java\:507) - objeto:45 posicion:5
17:08:14,871 [INFO] (frmBloqueoInstituciones.java\:507) - objeto:46 posicion:6
17:08:14,896 [INFO] (frmBloqueoInstituciones.java\:507) - objeto:47 posicion:7
17:08:14,921 [INFO] (frmBloqueoInstituciones.java\:507) - objeto:48 posicion:8
17:08:14,946 [INFO] (frmBloqueoInstituciones.java\:521) - Se borran los elementos
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1356)
at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1299)
at javax.swing.plaf.basic.BasicListUI.paintImpl(BasicListUI.java:251)
at javax.swing.plaf.basic.BasicListUI.paint(BasicListUI.java:227)
at javax.swing.plaf.synth.SynthListUI.update(SynthListUI.java:52)
at javax.swing.JComponent.paintComponent(JComponent.java:763)
at javax.swing.JComponent.paint(JComponent.java:1027)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5122)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:277)
at javax.swing.RepaintManager.paint(RepaintManager.java:1217)
at javax.swing.JComponent._paintImmediately(JComponent.java:5070)
at javax.swing.JComponent.paintImmediately(JComponent.java:4880)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:803)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:714)
at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:694)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
El codigo que tengo es el sig
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* frmBloqueoInstituciones.java
*
* Created on 29/05/2009, 05:45:33 PM
* Ultima modificación 29/07/2009
* Martin Reyes Montoya
*/
package org.banxico.dgobc.eint.Primaria_Gubernamental.GUI;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.TreeMap;
import javax.swing.DefaultListModel;
import org.apache.log4j.Logger;
import org.banxico.dgobc.eint.Primaria_Gubernamental.negocio.CtrlDatos;
import org.banxico.dgobc.eint.Primaria_Gubernamental.negocio.Globales;
import org.banxico.dgobc.eint.Primaria_Gubernamental.negocio.Institucion;
/**
*
* @author B10018
*/
public class frmBloqueoInstituciones extends javax.swing.JInternalFrame {
/** Creates new form frmBloqueoInstituciones */
public frmBloqueoInstituciones(mdiPrincipal mdi) {
initComponents();
this.mdi = mdi;
frmBloqueoInstituciones.estaCargada = true;
this.cargaInstituciones();
}
private void cargaInstituciones() {
TreeMap<Integer, Institucion> tmInstituciones = controlDatos.getTmInstituciones();
List<Integer> lstInstitucionesBloqueadas = controlDatos.getLstBancosBloqueados();
Iterator it = tmInstituciones.keySet().iterator();
Integer clave = null;
dlmBloqueados = new DefaultListModel();
dlmDesbloqueados = new DefaultListModel();
boolean esBloqueado = false;
List<String> lstBloqueados = new ArrayList<String>();
List<String> lstDesBloqueados = new ArrayList<String>();
while (it.hasNext()) {
clave = (Integer) it.next();
if ((clave.intValue() != Globales.CLAVE_BANXICO)
&& (clave.intValue() != Globales.CLAVE_MIRON)) {
esBloqueado = false;
Iterator itBloqueados = lstInstitucionesBloqueadas.iterator();
while (itBloqueados.hasNext() && !esBloqueado) {
int claveBloqueado = Integer.parseInt(itBloqueados.next().toString());
if (clave.intValue() == claveBloqueado) {
lstBloqueados.add(tmInstituciones.get(clave).getNombre()
+ " (" + clave.toString() + ")");
esBloqueado = true;
}
}
if (!esBloqueado) {
lstDesBloqueados.add(tmInstituciones.get(clave).getNombre()
+ " (" + clave.toString() + ")");
}
}
}
java.util.Collections.sort(lstBloqueados);
java.util.Collections.sort(lstDesBloqueados);
Iterator itB = lstBloqueados.iterator();
Iterator itD = lstDesBloqueados.iterator();
while (itB.hasNext()) {
dlmBloqueados.addElement(itB.next());
}
while (itD.hasNext()) {
dlmDesbloqueados.addElement(itD.next());
}
this.lstBancosDesbloqueados.setModel(dlmDesbloqueados);
this.lstBancosBloqueados.setModel(dlmBloqueados);
}
/** 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() {
jSplitPane1 = new javax.swing.JSplitPane();
jPanel2 = new javax.swing.JPanel();
jPanel4 = new javax.swing.JPanel();
chkSeleccionaTodosDesbloqueados = new javax.swing.JCheckBox();
cmdBloquear = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
lstBancosDesbloqueados = new javax.swing.JList();
jPanel3 = new javax.swing.JPanel();
jPanel5 = new javax.swing.JPanel();
chkSeleccionaTodosBloqueados = new javax.swing.JCheckBox();
cmdDesbloquear = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
lstBancosBloqueados = new javax.swing.JList();
cmdCerrar = new javax.swing.JButton();
setClosable(true);
setMaximizable(true);
setTitle("Bloqueo de Instituciones");
setToolTipText("Bloqueo de Instituciones");
addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
formInternalFrameClosed(evt);
}
public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
}
});
addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentMoved(java.awt.event.ComponentEvent evt) {
formComponentMoved(evt);
}
});
jSplitPane1.setDividerLocation(390);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Instituciones Habilitadas", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Comic Sans MS", 0, 11))); // NOI18N
jPanel2.setFont(new java.awt.Font("Comic Sans MS", 0, 11)); // NOI18N
jPanel2.setPreferredSize(new java.awt.Dimension(500, 479));
chkSeleccionaTodosDesbloqueados.setFont(new java.awt.Font("Comic Sans MS", 0, 11));
chkSeleccionaTodosDesbloqueados.setText("Seleccionar Todos");
chkSeleccionaTodosDesbloqueados.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chkSeleccionaTodosDesbloqueadosActionPerformed(evt);
}
});
cmdBloquear.setFont(new java.awt.Font("Comic Sans MS", 0, 11));
cmdBloquear.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Redo16.gif"))); // NOI18N
cmdBloquear.setText("Bloquear");
cmdBloquear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdBloquearActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addComponent(chkSeleccionaTodosDesbloqueados, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 129, Short.MAX_VALUE)
.addComponent(cmdBloquear, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cmdBloquear)
.addComponent(chkSeleccionaTodosDesbloqueados))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
lstBancosDesbloqueados.setFont(new java.awt.Font("Comic Sans MS", 0, 11)); // NOI18N
lstBancosDesbloqueados.setLayoutOrientation(javax.swing.JList.VERTICAL_WRAP);
lstBancosDesbloqueados.setVisibleRowCount(17);
lstBancosDesbloqueados.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lstBancosDesbloqueadosMouseClicked(evt);
}
public void mousePressed(java.awt.event.MouseEvent evt) {
lstBancosDesbloqueadosMousePressed(evt);
}
});
lstBancosDesbloqueados.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
lstBancosDesbloqueadosValueChanged(evt);
}
});
jScrollPane1.setViewportView(lstBancosDesbloqueados);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 413, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jSplitPane1.setLeftComponent(jPanel2);
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Instituciones Bloqueadas", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Comic Sans MS", 0, 11))); // NOI18N
jPanel3.setFont(new java.awt.Font("Comic Sans MS", 0, 11)); // NOI18N
chkSeleccionaTodosBloqueados.setFont(new java.awt.Font("Comic Sans MS", 0, 11));
chkSeleccionaTodosBloqueados.setText("Seleccionar Todos");
chkSeleccionaTodosBloqueados.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chkSeleccionaTodosBloqueadosActionPerformed(evt);
}
});
cmdDesbloquear.setFont(new java.awt.Font("Comic Sans MS", 0, 11));
cmdDesbloquear.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Undo16.gif"))); // NOI18N
cmdDesbloquear.setText("Desbloquear");
cmdDesbloquear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdDesbloquearActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addComponent(chkSeleccionaTodosBloqueados, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdDesbloquear)
.addContainerGap(137, Short.MAX_VALUE))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(chkSeleccionaTodosBloqueados)
.addComponent(cmdDesbloquear))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
lstBancosBloqueados.setFont(new java.awt.Font("Comic Sans MS", 0, 11)); // NOI18N
lstBancosBloqueados.setLayoutOrientation(javax.swing.JList.VERTICAL_WRAP);
lstBancosBloqueados.setVisibleRowCount(17);
lstBancosBloqueados.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lstBancosBloqueadosMouseClicked(evt);
}
public void mousePressed(java.awt.event.MouseEvent evt) {
lstBancosBloqueadosMousePressed(evt);
}
});
jScrollPane2.setViewportView(lstBancosBloqueados);
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 413, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jSplitPane1.setRightComponent(jPanel3);
cmdCerrar.setFont(new java.awt.Font("Comic Sans MS", 0, 11));
cmdCerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Stop16.gif"))); // NOI18N
cmdCerrar.setText("Cerrar");
cmdCerrar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdCerrarActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 793, Short.MAX_VALUE)
.addComponent(cmdCerrar, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdCerrar)
.addContainerGap())
);
pack();
}// </editor-fold>
private void cmdCerrarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dispose();
frmBloqueoInstituciones.estaCargada = false;
}
private void chkSeleccionaTodosDesbloqueadosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (this.chkSeleccionaTodosDesbloqueados.isSelected()) {
this.lstBancosDesbloqueados.setSelectionInterval(0,
this.lstBancosDesbloqueados.getModel().getSize() - 1);
} else {
this.lstBancosDesbloqueados.getSelectionModel().removeSelectionInterval(0,
this.lstBancosDesbloqueados.getModel().getSize());
}
}
private void chkSeleccionaTodosBloqueadosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (this.chkSeleccionaTodosBloqueados.isSelected()) {
this.lstBancosBloqueados.setSelectionInterval(0,
this.lstBancosBloqueados.getModel().getSize() - 1);
} else {
this.lstBancosBloqueados.getSelectionModel().removeSelectionInterval(0,
this.lstBancosBloqueados.getModel().getSize());
}
}
private void cmdBloquearActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (this.lstBancosDesbloqueados.getSelectedValues().length > 0) {
mdi.setTipoOperacionEnEjecucion(Globales.PW_SOLICITUD_BLOQUEO_INSTITUCIONES);
dlgPasswordOperacion dlg = new dlgPasswordOperacion(mdi, true);
dlg.setLocation(java.awt.Toolkit.getDefaultToolkit().getScreenSize().width / 2 - dlg.getWidth() / 2,
java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2 - dlg.getHeight() / 2);
dlg.setVisible(true);
} else {
mdi.showMsg("Aviso", "No ha seleccionado alguna institución, Verifique.",
frmMensaje.ImagenInformacion);
}
}
private void cmdDesbloquearActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (this.lstBancosBloqueados.getSelectedValues().length > 0) {
mdi.setTipoOperacionEnEjecucion(Globales.PW_SOLICITUD_DESBLOQUEO_INSTITUCIONES);
dlgPasswordOperacion dlg = new dlgPasswordOperacion(mdi, true);
dlg.setLocation(java.awt.Toolkit.getDefaultToolkit().getScreenSize().width / 2 - dlg.getWidth() / 2,
java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2 - dlg.getHeight() / 2);
dlg.setVisible(true);
} else {
mdi.showMsg("Aviso", "No ha seleccionado alguna institución, Verifique.",
frmMensaje.ImagenInformacion);
}
}
private void lstBancosDesbloqueadosValueChanged(javax.swing.event.ListSelectionEvent evt) {
// TODO add your handling code here:
}
private void lstBancosDesbloqueadosMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
private void lstBancosBloqueadosMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
private void lstBancosDesbloqueadosMousePressed(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
this.chkSeleccionaTodosDesbloqueados.setSelected(false);
}
private void lstBancosBloqueadosMousePressed(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
this.chkSeleccionaTodosBloqueados.setSelected(false);
}
private void formComponentMoved(java.awt.event.ComponentEvent evt) {
// TODO add your handling code here:
frmBloqueoInstituciones.posX = this.getX();
frmBloqueoInstituciones.posY = this.getY();
}
private void formInternalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
// TODO add your handling code here:
frmBloqueoInstituciones.estaCargada = false;
}
public void solicitaBloqueoInstituciones() {
Object[] valores = this.lstBancosDesbloqueados.getSelectedValues();
short[] clavesPorBloquear = new short[valores.length];
if (valores.length > 0) {
for (int i = 0; i < valores.length; i++) {
clavesPorBloquear[i] = Short.valueOf(valores[i].toString().substring(
valores[i].toString().indexOf("(") + 1, valores[i].toString().indexOf(")")));
}
// for(int i=0; i<clavesPorBloquear.length; i++)
// {
// System.out.println("Valores: " + clavesPorBloquear[i]);
// }
mdi.sendSolicitudBancosPorBloquear(clavesPorBloquear.length, clavesPorBloquear);
}
}
public void solicitaDesBloqueoInstituciones() {
Object[] valores = this.lstBancosBloqueados.getSelectedValues();
short[] clavesPorDesBloquear = new short[valores.length];
if (valores.length > 0) {
for (int i = 0; i < valores.length; i++) {
clavesPorDesBloquear[i] = Short.valueOf(valores[i].toString().substring(
valores[i].toString().indexOf("(") + 1, valores[i].toString().indexOf(")")));
}
// for(int i=0; i<clavesPorBloquear.length; i++)
// {
// System.out.println("Valores: " + clavesPorBloquear[i]);
// }
mdi.sendSolicitudBancosPorDesBloquear(clavesPorDesBloquear.length, clavesPorDesBloquear);
}
}
public void quitaInstitucionesPorBloquear() {
int[] indices = this.lstBancosDesbloqueados.getSelectedIndices();
Object[] valores = this.lstBancosDesbloqueados.getSelectedValues();
logger.info("==>> quitaInstitucionesPorBloquear" + " cuantos tiene:" + valores.length + " indices:" + indices.length);
for (int i = 0; i < indices.length; i++) {
logger.info("objeto:" + indices[i] + " posicion:" + i);
dlmBloqueados.addElement(valores[i]);
//dlmDesbloqueados.removeElement(valores[i]);
try {
Thread.sleep(25);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
if (chkSeleccionaTodosDesbloqueados.isSelected()) {
dlmDesbloqueados.removeAllElements();
} else {
logger.info("Se borran los elementos");
for (int i = indices.length - 1; i >= 0; i--) {
try{
dlmDesbloqueados.remove(indices[i]);
} catch (NullPointerException e) {
logger.info("Se borran los elementos");
}
}
}
this.chkSeleccionaTodosDesbloqueados.setSelected(false);
}
public void quitaInstitucionesPorDesBloquear() {
int[] indices = this.lstBancosBloqueados.getSelectedIndices();
Object[] valores = this.lstBancosBloqueados.getSelectedValues();
logger.info("<<== quitaInstitucionesPorDesBloquear" + " cuantos tiene:" + valores.length + " indices:" + indices.length);
for (int i = 0; i < indices.length; i++) {
logger.info("objeto:" + indices[i] + " posicion:" + i);
dlmDesbloqueados.addElement(valores[i]);
try {
Thread.sleep(25);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
if (chkSeleccionaTodosBloqueados.isSelected()) {
dlmBloqueados.removeAllElements();
} else {
logger.info("Se borran los elementos");
for (int i = indices.length - 1; i >= 0; i--) {
try {
dlmBloqueados.remove(indices[i]);
} catch (NullPointerException e) {
logger.info("Se borran los elementos");
}
}
}
this .chkSeleccionaTodosBloqueados .setSelected(false);
}
// Variables declaration - do not modify
private javax.swing.JCheckBox chkSeleccionaTodosBloqueados;
private javax.swing.JCheckBox chkSeleccionaTodosDesbloqueados;
private javax.swing.JButton cmdBloquear;
private javax.swing.JButton cmdCerrar;
private javax.swing.JButton cmdDesbloquear;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JList lstBancosBloqueados;
private javax.swing.JList lstBancosDesbloqueados;
// End of variables declaration
private mdiPrincipal
mdi = null;
public static boolean
estaCargada = false;
public static final long
serialVersionUID = 0L;
private static final Logger
logger = Logger.getLogger(frmConsulta.class);
private DefaultListModel dlmBloqueados = null;
private DefaultListModel dlmDesbloqueados = null;
private static CtrlDatos controlDatos = CtrlDatos.getInstance();
public static int posX = 0, posY = 0;
}
/*******************************************************************************************************************************************************/
Alquien q me pueda orientar al respecto o que tenga algo parecido se los agradecere.
Saludos
- Inicie sesión o regístrese para enviar comentarios
Al parecer a tu componenente
Al parecer a tu componenente no le gusta quedarse sin elementos que desplegar. Todo funciona bien hasta que tu Default model se queda en cero. Revisa que hace tu componenente cuando no tiene elementos y/o si le puedes poner un valor por default.
Otra cosa, ya te habras dado cuenta que si escribes:
} catch ( NullPointerException npe ) {
logger.info("...");
}
Su codigo sigue comportandose raro. Lo mejor es que no tengas NullPointerExceptions en primer lugar.
Tambien, quita esta codigo, espero que solo lo tengas para depurar la aplicacion:
Thread.sleep(25);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
mismo problema
ya elimine los try q me comentas, sin embargo ahora pongo la sig validacion cuando trato de borrar
for (int i = indices.length - 1; i >= 0; i--) {
if (!dlmDesbloqueados.isEmpty()){
dlmDesbloqueados.remove(indices[i]);
}
pero sigo teniendo el mismo problema.
Que otra alternativa tengo.