• 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

shouldSelectCell() in DefaultCellEditor not working?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;

}

}
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic