Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

shouldSelectCell() in DefaultCellEditor not working?  RSS feed

 
Micha Jones
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have created a simple class that extends DefaultCellEditor (see below), but it appears that shouldSelectCell() is not working - the cell's contents do not get selected.
Advice much appreciated!!
class PaymentCellEditor extends javax.swing.DefaultCellEditor {

public PaymentCellEditor(javax.swing.JTextField textField){
super(textField);
clickCountToStart = 1;

}

public boolean shouldSelectCell(java.util.EventObject anEvent) {

return true;

}

}
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tested out your cell editor and it seemed to work correctly. You should post the code where you use this cell editor, so that we can see if there are any setting on the JTable that may interfere with the cell editor working properly...

(You may also be confused about what the shouldSelectCell() method does... I admit.. the 1.3 APIs made it much more clear than the 1.4 APIs...)
 
Micha Jones
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm. It's likely that my code has so many other things going on; custom table model and sorter, etc. etc. The solution I managed to work out was to catch the focus event in the cell itself:
MyCellEditor editor = new MyCellEditor(new javax.swing.JTextField(){
protected void processFocusEvent(FocusEvent e) {
super.processFocusEvent(e);
this.selectAll();
}
});

But I definitely appreciate the response!
Cheers!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!