• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

detect if JTable column contains string "blabla"

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
which classes related to the JTable should i use so i can check if a table column contains a certain string
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark ,

I think you can use the DefaultTableCellRenderer class
And this class has a method
public Component getTableCellRendererComponent(JTable table,Object obj, boolean isSelected, boolean hasFocus, int row, int column)
You can ovrride the method and can check table value......

Thanks
Renjith M
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi tv, thanks. yes you are right.

but what i want to do is something like this

jTable.getColumn("column_name").doesStringExistInColumn(); returns boolean

something like that.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

T.V.M Renjith wrote:
I think you can use the DefaultTableCellRenderer class
public Component getTableCellRendererComponent(JTable table,Object obj, boolean isSelected, boolean hasFocus, int row, int column)



Not really.
The renderer is like a rubber stamp for the visualization part and the method you mention returns a visual component.
Remember MVC. The visualization should be independent of the data.

The proper way to do it would be to query the table model for the required data.
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks.

been searching but found no possible way to shorten the solution. so i used getValueAt() and checked each row of the tablemodel.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mark chester goking wrote:thanks.

been searching but found no possible way to shorten the solution. so i used getValueAt() and checked each row of the tablemodel.



Bingo!
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic