Searching in a JTable

Searching in a JTable

Page 1 of 1

3 Replies - 9630 Views - Last Post: 06 March 2009 - 10:49 AM Rate Topic: -----

#1 leitbug06  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 05-January 09

Searching in a JTable

Posted 01 March 2009 - 03:13 PM

I am creating a database of products for a company. The products are in an array and I am going to create a JTable and fill the cells with the contents of the array. I would like the table to be searchable, by this I mean that there would be a JTextArea and the user could type what they wanted to search for and the contents of the table that did not contain what was searched for would disappear. I found a way to filter the table, but that does the exact opposite of what I want to do. Is searching in a JTable in this manner possible? Also, if it is possible, I do not want the code or anything for how to do it, but a hint or suggestion to lead me in the correct path would be very helpful.

Is This A Good Question/Topic? 0
  • +

Replies To: Searching in a JTable

#2 BigAnt  Icon User is offline

  • May Your Swords Stay Sharp
  • member icon

Reputation: 102
  • View blog
  • Posts: 2,392
  • Joined: 16-August 08

Re: Searching in a JTable

Posted 01 March 2009 - 03:46 PM

When doing the searching just refresh the JTable with the values from the array which match the text.

i.e. When the user enters their text just redo the Jtable containing only the values that they are searching for.
Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Searching in a JTable

Posted 01 March 2009 - 06:46 PM

View Postleitbug06, on 1 Mar, 2009 - 02:13 PM, said:

I am creating a database of products for a company. The products are in an array and I am going to create a JTable and fill the cells with the contents of the array. I would like the table to be searchable, by this I mean that there would be a JTextArea and the user could type what they wanted to search for and the contents of the table that did not contain what was searched for would disappear. I found a way to filter the table, but that does the exact opposite of what I want to do. Is searching in a JTable in this manner possible? Also, if it is possible, I do not want the code or anything for how to do it, but a hint or suggestion to lead me in the correct path would be very helpful.

A JTable is just a tool to display data (usually coming froma Vector)
you should not search the JTable.... you should search the source (whatever it is) from which the JTable is displayed

You are trying to scan the spidometer of a car and interpret the scanned image rather than looking at the number of the time the wheels turn in a second
Was This Post Helpful? 0
  • +
  • -

#4 leitbug06  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 05-January 09

Re: Searching in a JTable

Posted 06 March 2009 - 10:49 AM

Thank you for the information!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1