Ranganathan Kaliyur Mannar wrote:Hi,
I looked at the code. Basically, the list is being added to and removed for the table to refresh. So, if you are doing a rollback, call em.refresh() for that entity and then remove that object from the list and add it again to the list. This should refresh the table.
Ranganathan Kaliyur Mannar wrote:First of all, where is the call to refresh()? It should be called whenever an exception occurs and rollback has happened.
More importantly, you need not refresh the entire contents. Just refresh the entity that you are referring to (i.e the one you tried to save and rolled back). And normally, whenever the table data model is changed, it would call its fireXXX methods to notify the JTable to update itself. You need to see if that happens in this case.
Ranganathan Kaliyur Mannar wrote:Why do have so many calls to 'entityManager.getTransaction().begin()' ?
and you re calling begin even after a 'rollback' or 'commit' is done...
as for the rollback issues, I think you can do a entityManager.refresh for that entity which should then have the correct data which will be reflected in the JTable...
Michael Dunn wrote:> so I'm using a custom renderer to display the name of the Customer
instead of using a renderer, create a Customer class where you override
toString() to return the customer's name, then just read the db data into
Customer objects and add them to the comboBox (which will display only
the customer's name).
Karthik Shiraly wrote:This doesn't seem to be all that simple. It behaves differently in different look and feels - in Metal, the background color is simply ignored for the body but used for the arrow(??) and the list, while in Windows system look and feel, it works fine.
What L&F are you using - what's the OS?
In my Win7 system, I had to just setBackground of combobox to pink; it worked as expected even with a custom renderer and regardless of focus. I didn't need to set background of renderer at all.
But it worked very differently in other L&Fs.
Rob Spoor wrote:Call setBackground(...) with a value dependent on the isSelected argument.