• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

jtable

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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: 22001
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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: 22001
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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?

 
Creativity is allowing yourself to make mistakes; art is knowing which ones to keep. Keep this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic