• Post Reply Bookmark Topic Watch Topic
  • New Topic

TableModels value getting changed  RSS feed

 
Bill White
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am having a problem with some event code and TableModel.
I have my own class that holds the data important to me for that row it all works fine and dandy.
However when I double click in a cell, the models object type gets changed to a String. (VERY VERY BAD).
Here is my code:
public void mouseReleased(MouseEvent e)
{
boolean isLeftClicked = SwingUtilities.isLeftMouseButton(e);
if(isLeftClicked)
{
int row = getSelectedRow();

CellValue fileName =
(CellValue)tableModel.getValueAt(row, 0);

int count = e.getClickCount();
if(count == 2)
{
if(fileName.isDirectory())
{
// Do Something usefull
} // if
} // if count == 2
} // is isLeftClicked
}

Sorry for the formatting.
Is there something I am suppose to set to prohibit this from happening?
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First thing that comes to my mind is:
(double) clicking normally activates the CellEditor.
THUS:
- you have implemented a CellRenderer for your special data type which works fine
- you have NOT implemented or added a CellEditor for your special data type
OR: the cells are editable while they should not be.
(to change the latter: overwrite isCellEditable in your table model)
chantal
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!