File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JTable problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable problem" Watch "JTable problem" New topic

JTable problem

sri rallapalli
Ranch Hand

Joined: Mar 15, 2005
Posts: 88
I am working in swings now, and I am new to this.

I have one requirement where in which

1st screen contains a text box, and a search button, so I need to enter a value, and I need to click the search button. After clicking the search button, it should display another screen, where it should contain a JTable with 5 colums, and 3 buttons (ADD, EDIT, DELETE).

1. I have to display some set of records in a table, table contains 5 columns, �result set� from the database may contain more records; it should display the values in the 5 columns for all the records.

2. From the JTable with the set of records, I can select a row, and click the ADD, EDIT, DELETE button, then it should display those values of the 5 columns for that particular row in text boxes in a new window, again it should contain 2 buttons, ok, cancel.

3. If I click on the ok button, first it should store in the database, and at the same time it should refresh the table contents with the new values.

I have done it but it is not working properly. What I did was, after displaying the values in the JTable, and then after clicking edit button, I am entering the values, it is updating the database, but, while to see the reflected values I need to do an Alt-Tab, and select the window, then only I am able to see the content otherwise I am not able to see the reflected contents.

Please suggest me a solution.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

First, it's not swings. It's singular: Swing.

As to your problem; it is probably a combination of the TableModel not calling it's fireTableChanged even and/or that event not being called on the Event Dispatching Thread. The reason you see the updates after you do your ALT-TAB thing is because bringing the table out of focus and back into focus repaints the table properly.

Are you using a TableModel for your data? If so, could you provide the code as well as the code for you Add/Edit/Delete events?

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: JTable problem
It's not a secret anymore!