• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

jtable

 
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 a table with 5 columns. I was required to validate column 3 and 5 for numeric input.

I could validate numeric cell by cell.
If I do that, I need to write the code for each cell.

Please suggest how I can iterate the column 3 and 5 for the validation
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just use a TableModel implementation (often a (anonymous) DefaultTableModel subclass) that overrides getColumnClass to return Integer.class for columns 3 and 5. JTable has built-in support for numbers, so there will be validation upon input.
 
jonathan benz
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Rob

Here i would like to display a JOptionMessageDialog message for non-numeric value for column 1 and 2 only

 
Rob Spoor
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you want to display a dialog? The red border you get now is much less intrusive.
 
jonathan benz
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Rob.

I need to popup an alert message for the user to key-in numeric values.
This system is a questionnaire targeting for the public to give their feedback.

So, it will be more informed if the system prompt an alert message rather than the red line.

please help how can i make an alert instead the red bolder?

 
Can you hear that? That's my theme music. I don't know where it comes from. Check under this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic