• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

JTable problem

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic