*
The moose likes Swing / AWT / SWT and the fly likes JTable update 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 "JTable update" Watch "JTable update" New topic
Author

JTable update

PriyaRajan
Greenhorn

Joined: Nov 09, 2001
Posts: 4
Dear friends,
I have problem in updating JTable. My program get i/p data for the table from other classes and tries to update the table. isCellEditable() is false, because I dont want user to type anything in my table. when the table data changes, it fires fireTabledatachanged() event.
I am extending AbstractDataModel() class and my table data is stored in a hashtable. The data changes very fast. so to avoid flickering, I moved from applets to JApplet and I am using JTable. Is there anyother choice available for me?
where to put the code for update in my (DataModel)class? setvalueat(row,col) is not possible for me, since I use hashtable. I cannot use arrays, since the datatypes are varying and the length of the table also grows dynamically.
Thank u,
Priya
mohana konakanchi
Ranch Hand

Joined: May 16, 2001
Posts: 67
if your using hashtable, better make row and col number as key
so that you can use setValueAt()
public void setValueAt(Object value, int row, int col)
{
myHashTable.put(row+"-"+col,value);
fireTableCellUpdated(row, col);
}
Other solutions depends on the way you implementing table model using hashtable. And what do you mean by dynamic table rows?
Mohana
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JTable update