• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Refresh rows of a JTable

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use Code Tags
 
reply
    Bookmark Topic Watch Topic
  • New Topic