wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Problem in JTable Renderer and Editor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem in JTable Renderer and Editor" Watch "Problem in JTable Renderer and Editor" New topic
Author

Problem in JTable Renderer and Editor

Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Hi All

I have created a JTable with one Column have the Custom TableCellRenderer, and TableCellEditor

Which has the a JPanel with one lable and a button.

Problem is:

I have to edit the content of table by clicking the button, i will select some data from another dialog,

if i select that data the cell contenet is not updating, and i can not able to select any other cell in the table.

if i resize the colomn the above problem will solve.

Please help on this to fix

-Chiru
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Your table will not display the new data unless you update the model using the appropriate model methods. Are you doing that?
If yes, please post a sscce code which demonstrates your problem.
Note: Please do take out time to visit the link I provided to find out what sscce really means.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Renderer Class

And The Editor Class


Sorry i am not able to copy paste the code because they disabled all those in office.
If you need some more code please tell me i will try to type it
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Sorry i did not created any model for that Table
i just created the JTable using JTable(Object[][] data,String[] colNames) Constructor
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Please read my reply carefully.
I had asked you if you are updating the model with the new values. All you have told me is you had forgotten to create the model and a bunch of code which is not SSCCE.
If you cannot take efforts to help us help you, I do not see what else can be done.
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Sorry i made some thing wrong,

Can you tell me what al the methods i have to handle in Model class,
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Check out the default/abstract/table model API. You will notice methods which will insert,delete,update the data

In pseudo code
1) Define a table model
2) Create a table using that model
3) When you want to modify the table data, modify the table model
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Thanks Maneesh

I fixed the issue, but still repaint is not happening. But i can select any cell for editting the cell.

The Solution is to make the stopCellEditing() method should return true;


Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Hi Maneeh
For the repainting the JTable:
The issue was i have to call fireEdittingStopped(); in th Editor after closing the dialog

Its working fine now, Thanks for your support.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem in JTable Renderer and Editor
 
Similar Threads
how to update JTable values
JComboBox in JTable
radio button selection in jtable
JTable
JTable ........