• Post Reply Bookmark Topic Watch Topic
  • New Topic

Refresh rows of a JTable  RSS feed

 
ram shyam
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

In a Jtable, on selecting one of the rows and pressing F5 (to refresh the data), the data in the corresponding cell (which was selected), gets vanished and empty cell is displayed. In my code, the functionality of refresh is just to get the table data again and populate which works correctly but the corresponding cell data alone is removed and only an empty cell appears.

Please let me know if my TableModel or the TableCellEditor is missing out anything related to this.

Thanks in advance!!
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See you should always provide the code which is causing problem along with your question, so that people here can easily get to your problem and reply you soon
 
ram shyam
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The problem is that I am not able to find in which part of my module is causing this issue. I cannot paste the entire code here. Thats the reason, I am asking if anything has to be done in specific in the Tablemodel when the table data has to be refreshed.

==============TableModel code=======================================

private AbstractTableModel dedicatedAccountsDataModel
= new AbstractTableModel()
{
public String getColumnName(int col)
{
return dedicatedAccountsColumnHeadings[col];
}
public int getRowCount()
{
return dedicatedAccountsData.size();
}
public int getColumnCount()
{
return dedicatedAccountsColumnHeadings.length;
}
public Object getValueAt(int row, int col)
{
Object value = "";
Object spclValue = "";
String newValue = "";

try
{
ArrayList oldData = (ArrayList)Session.getCurrentController().getCurrentModel().getOriginalValue(DedicatedAccountsSubModel.DEDICATED_ACCOUNTS);
java.util.List rowSet =
(ArrayList) dedicatedAccountsData.get(row);
if (col != 5)
{
value = rowSet.get(col);
return value;
}
else
{
newValue = rowSet.get(3).toString();
if (!(newValue.equals(((ArrayList)oldData.get(row)).get(3).toString())))
{
spclValue = undoButton;
return spclValue;
}
}
}
catch (Exception e)
{
fireTableCellUpdated(row, col);
} // do nothing - only catch for compiler
return value ;
}
public boolean isCellEditable(int row, int col)
{
if(isFlag)
return true ;
else
return false;
}
public void setValueAt(Object value, int row, int col)
{
java.util.List rowSet = (ArrayList) dedicatedAccountsData.get(row);
rowSet.set(col, value);
fireTableRowsUpdated(row, row);
dedicatedAccountsTable.scrollRectToVisible(dedicatedAccountsTable.getCellRect(row, 0, true));
}
};

=========================================================================

Please advice.

Thanks in advance!!
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use Code Tags
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!