Connecting Tech Pros Worldwide Forums | Help | Site Map

JButton-problem: new JFrame with a JTable updates only after second click

Newbie
 
Join Date: Jul 2008
Posts: 1
#1: Jul 10 '08
Hi,

I'm trying to create a button that opens a new window for setting up a whole crapload of constants for an analysis program.

For this, I have a JButton. The actionPerformed-method activates another method in the master class, which creates a new JFrame. The JFrame contains a JTable which has it's own TableModel, also residing within the master class. The JTable reads it's data from an array, which is updated or not depending on the user's choice (save/cancel buttons in the new window). When the new window is closed, the JFrame is disposed() of.

The problem is that the first time the new JFrame becomes visible only after the 2nd click of the button. After that it opens with every click. But, any updates made to the editable JTable are not visible the very next time the new window is opened, but become visible after that. So, almost everything runs one click too late.

Maybe it's some kinda thread problem? Since I call the frame-creating-method from the actionPerformed-method, I suppose the control stays with the Event Dispatching Thread, but creating the table and the new frame shouldn't take much time, so I don't see how that would be a problem.

Any help would be much appreciated! Regards,
Gimzo

Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,466
#2: Jul 10 '08

re: JButton-problem: new JFrame with a JTable updates only after second click


Hi Gimzo!
I've faces similar problems in the past and it was always a coding problem. So please post some relevant code and then we can try to help you.

Greetings,
Nepomuk
Reply