How to make a table field to accept only numbers.
If it is any other (key), it should not display it in that field.
IS that possible? If so please let me know.
How to make a table field to accept only numbers. If it is any
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I must admit I have not tested this, but the default
JTablehas an inner classNumberEditor(javax.swing.JTable.NumberEditor). So I assume that when yourTableModelcorrectly indicates the column class is a number extension, the default editor will be one that only accepts numbersIf the default editor is not what you are looking for, you can write your own editor, for example by using a
JFormattedTextFieldas editor. See the Swing table tutorial for more information. This tutorial contains a section about a custom editor which should get you started if you want to write your own editor.