• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic