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]
# 1
Post a small, succinct example of the code that is causing you problems.Also, this is a Swing related question and should be placed in the Swing forum.
filestreama at 2007-7-12 9:11:24 > top of Java-index,Java Essentials,Java Programming...
# 2

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 > top of Java-index,Java Essentials,Java Programming...
# 3
It looks okay however, you might be complicating things.You are passing in an array of java.awt.Components that are associated with the container. Why not just en/disable them? Unless you have containers within containers which is not clear from your original post.
filestreama at 2007-7-12 9:11:24 > top of Java-index,Java Essentials,Java Programming...
# 4
I get the felling you need to look at the swing worker example.
macrules2a at 2007-7-12 9:11:24 > top of Java-index,Java Essentials,Java Programming...
# 5
> I get the felling you need to look at the swing> worker example.Yes, be aware of how Swing needs to be treated with respect to threads: http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html
DrLaszloJamfa at 2007-7-12 9:11:24 > top of Java-index,Java Essentials,Java Programming...
# 6
Yeah filestream, I have lots of components and all of them need to be disable. The unique component that I'm having problem is the JTable.All the others are functioning ok!!I'll have a look in this example!!If someone else has other
Gina at 2007-7-12 9:11:24 > top of Java-index,Java Essentials,Java Programming...
# 7
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.
filestreama at 2007-7-12 9:11:24 > top of Java-index,Java Essentials,Java Programming...