• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable focus problem  RSS feed

 
Gary Martinkus
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTable that has a custom editor. I am validating a cell entry and then attempting to clear that cell entry and keep the user in that same cell if it is an invalid entry. I have accomplished the clearing of the invalid data in the cell, but am unable to keep the focus on the current cell after the data has been cleared. The portion of the custome cell editor is below, thanks.
public Object getCellEditorValue() {
// Set heirarchy row values.
int currRow = detailTable.getEditingRow();
int currColumn = detailTable.getEditingColumn();
String subTable = (String)detailTable.getValueAt(currRow, 0);

// Don't validate the criteria if it is null.
if (((JTextField)component).getText().length() > 0) {
// Validate the criteria.
if (!datasourceConnection.validSqlStatement(subTable, ((JTextField)component).getText())) {
// Invalid criteria, clear the criteria field.
JOptionPane.showMessageDialog(null, "This is an invalid criteria entry.", "Criteria Status", JOptionPane.ERROR_MESSAGE);
((JTextField)component).setText("");
detailTable.setColumnSelectionAllowed(true);
detailTable.setRowSelectionAllowed(true);
detailTable.changeSelection(currRow, currColumn, false, false);
}
}

// Return the field value.
return ((JTextField)component).getText();
}
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you requesting focus for the cell anywhere?

(see http://developer.java.sun.com/developer/bugParade/bugs/4224061.html)
chantal
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!