Problems with enable JTable
Hello people!!
I have the following situation: I have swing window and inside this I have a JTable.
I need to make somethings and during this process I have to dis-enable the JTable, so what I'm doing:
before everything
jTableX.setEnable(false);
make all the things
after all
jTableX.setEnable(true);
But, after that I can't select any register anymore!!
What's the problem?
Thanks in advance!!
Gin
[540 byte] By [
Gina] at [2007-11-27 4:06:18]

Ok!!
protected void buscaBoletos() {
Runnable run = new Runnable() {
public void run() {
try {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
ativarDesativarComponentes(getComponents(), false);
//complex code
} catch (Exception e) {
e.printStackTrace();
mostrarMensagemWarning(e.getMessage(), titulo);
} finally {
Toolkit.getDefaultToolkit().beep();
setCursor(Cursor.getDefaultCursor());
ativarDesativarComponentes(getComponents(), true);
}
}
};
Thread t1 = new Thread(run);
t1.start();
}
protected void ativarDesativarComponentes(Component[] componentes, boolean isAtivar) {
for (int i = 0; i < componentes.length; i++) {
Component componente = componentes[i];
if (!(componente instanceof JLabel)) {
componente.setEnabled(isAtivar);
}
if (componente instanceof Container) {
Container container = (Container) componente;
ativarDesativarComponentes(container.getComponents(), isAtivar);
}
}
}
Thanks anyway!!
Gin
Gina at 2007-7-12 9:11:24 >

Look into Swing threading issues, event thread, etc. as posted by mac & Laszlo.Try making a smaller example. Like a JFrame with a JPanel which has a JTable plus a JLabel plus one other component. See if you can get that to work.