wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Making JTable Non - Editable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Making JTable Non - Editable" Watch "Making JTable Non - Editable" New topic
Author

Making JTable Non - Editable

Vaskar Dasgupta
Greenhorn

Joined: Jul 20, 2001
Posts: 25
Hi,
Nathan its been a long time since i wrote to you, and i hope you arent missing any of your last trains to your home. Coming to business,
I would like to display a ResultSet in a JTable. How do i make the JTbale Non-Editable.
Secondly the JTable does not get repainted/refreshed when i display the next ResultSet rather it is overlapped on the earlier displayed data.
A sample code will be more appreciated.


Kindly reply back.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
You create your own table model and return false in the isCellEditable().
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Could you post the code related to the table that you already have? It is easier to just fix what is wrong and not worry about the rest of the things you already have that work.

Paul is right about overriding isCellEditable() to make your table non-editable... it sounds like the other problem you are having is due to either update problems, or problems with the renderers you are using for your table... without seeing code I am not sure which...

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Hi Vaskar,
Once you have your DataModel up and running ypou can stick in the methods you need to update the table the way you like.
Your DataModel class should have a Vector of Vectors for data to allow you to add and remove data freely.
Your data modification methods just modify the DataModel's data Vector according to your needs and then invoke a fireTableXXXChanged() call on the tablemodel to force the revalidating of the relevant cells - there are several of these to allow you to update parts or all the data as needed.
Hope that helps,


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
 
wood burning stoves
 
subject: Making JTable Non - Editable