Swing - How to search JTable's Content
Dear Friend
Could any one please help me in Finding out the JTable's Content with a Search key word.
That in the JTable Content is displayed, Suppose i want to search a Name Let's say "Jofin". When i enter jofin The Entire Row should be Selected. and i want to read the Selected Rows Record.
Please give me an ideas or samples to do this
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
class Testingextends JFrame
{
String colNames[] ={" string1 ","String2","String2"};
Object[][] data ={{"jothi","vimal","raj"},
{"jony","brito","kumar"},
{"kuru","banner","selvam"}};
DefaultTableModel dtm;
public Testing()
{
setLocation(50,50);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JTable table =new JTable(data,colNames);
JScrollPane sp =new JScrollPane(table);
JLabel lbl =new JLabel("SREACH:");
JTextField txt =new JTextField(20);
JPanel pnl =new JPanel();
pnl.add(lbl);
pnl.add(txt);
getContentPane().add(sp);
getContentPane().add(pnl,BorderLayout.SOUTH);
pack();
}
publicstaticvoid main (String[] args){
new Testing().setVisible(true);}
}
You can run my code and tell me how to solve this
Thank you
jofin

