• Post Reply Bookmark Topic Watch Topic
  • New Topic

Verify input in jTable except for head row  RSS feed

 
Viktoria Silver
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

I have a jTable with doubles or integers in every cell except for the top row, which can be user changed too, but can contain anything.
How can I validate user input for it being a numeric value?

I know there is an approach like this:
table.getColumnModel().getColumn(x).setCellEditor(CustomEditor())

but if I use this on every column the top row will be restricted to.
Maybe there there is a way for validating rows instead of columns?

Thank you, all help appreciated!
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Override the table method getCellEditor(...). If the row is 0, return a default editor otherwise return super.getCellEditor()
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!