Why does this code throws ClassCastException
.when I am trying to set selected row value of JTable(ie.showItem
) to a TextField (ie.itemCode
).Exception is Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
showItem = new JTable();
showItem.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int rowCount=showItem.getRowCount();
if(rowCount>=1){
//Why it is throwing ClassCastException
itemCode.setText((String)showItem.getValueAt(showItem.getSelectedRow(), 0));
}
}
});