• Post Reply Bookmark Topic Watch Topic
  • New Topic

Validating text and sorting in JTables-urgent

 
lakshmivenkatesan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I have to dynamically add rows and validate the user entered text in JTable.Also I have to limit the users from entering ,say more than 5 letters,in a cell.I tried using the DefaultCellEditor for a JtextField in each cell and I tried to Trap the KeyEvent of the textfield.But it doesn,t work.Please help.

Also,if I have ComboBoxes in my JTable,after selecting a value in the combo,the sorting order of the Table changes randomly.Please help out
Regards,
lakshmi
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the java tutorial on JTextField validation http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html#validation You will just need to modify the WholeNumberField example to check the length in the PlainDocument portion.
 
lakshmivenkatesan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanx for your reply.I am able to validate the Table by putting my validation code in the TableModel's setValueAt() method.
But the sorting problem has remained a big headache.I downloaded the TableSorter from the sun's site3.
But the user gets really confused after changing the combo value in a column,as the Table gets sorted randomly after that. I have added Selectionlistener to the table and I tried to manually sort the table everytime.But nothing is working.
I will be very grateful if someone helps me out
Regards,
lakshmi
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


"lakshmivenkatesan"
your name doesn't agree with the javaranch guidelines.
please take a moment and re-register after reviewing the
guidelines at http://www.javaranch.com/name.jsp
thanks for your cooperation.
- satya
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!