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

JTable focus problem

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);
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)
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
    Bookmark Topic Watch Topic
  • New Topic