Hi all
I am programming a database-related application in Java(with msaccess). I have to facilitate several different types of queries, but I'd like to use the same JTable to display the results of each query (one at a time, of course).
Initially the Jtable display all records.
JTable tableview;
dataModel=new DefaultTableModel(details,heading);
tableview = new JTable(dataModel);
tableview.setEnabled(true);
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
dis=new JScrollPane(tableview,v,h);
dis.setBounds(30,200,900,500);
c.add(dis);
dis.setVisible(true);
I have one combo box. that contain several pin number. If i select one pin number then the Jtable display that particular pin number records only.
rs2=st2.executeQuery("Select * from account where pin_number="+s);
int i=0;
while(rs2.next())
{
//assign the value to details[][];
}
dataModel=new DefaultTableModel(details,heading);
tableview = new JTable(dataModel);
I could not find any methods to update the contents of the JTable. I tried creating a new JTable object and adding that to the container.but nothing worked.
please help me.