I am writing a prg which take a value from user and check weather its present in table or not....

table.getValueAt(i,j).toString().toLowerCase() == searchfield.getText().toLowerCase();

Well if yes then make that cell red...

What to write to make cell red?

THANX , EZZARAL , but how to select a cell from coding.. what u posted only related to highlighting.

I HAVE DONE IT.... BUT ONLY A SINGLE CELL, I WANT TO SELECT ALL CELL WHICH HAS DATA...

table.getSelectionModel().setSelectionInterval(i,i);				table.getColumnModel().getSelectionModel().setSelectionInterval(j,j);

YES I DID IT

for(int i=0;i<table.getRowCount();i++)
					for(int j=0;j<table.getColumnCount();j++)
						if(table.getValueAt(i,j).toString().toLowerCase().equals(searchfield.getText().toLowerCase()))
						{
							
							table.getSelectionModel().setSelectionInterval(i,i);
							table.getColumnModel().getSelectionModel().setSelectionInterval(j,j);
						}

BUT IT ONLY SELECT A SINGLE CELL, NOT ALL MATCHING CELL

You can add various selection intervals through the methods on ListSelectionModel, but setting multiple, non-contiguous single cells is tricky and not really that useful.

You are better off highlighting them and perhaps selecting the first.

Edited 5 Years Ago by Ezzaral: n/a

Found solution..... and it worked great.

table.changeSelection(i,j,true,false);

u must give me a reputation point on finding such a solution for this forum :) Joking, and thanx for helping.

Nice work. I never noticed that method before - never had to select a bunch of single cells either though.

This question has already been answered. Start a new discussion instead.