• 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

JTable focus problem

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
}
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic