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);
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
dis=new JScrollPane(tableview,v,h);

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;
   //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.

you can use for loop to collect all the values from JTable i have used this for my project hope this may be helpful to u

for(int i1=0;i1<rows;i1++)
						for(int j1=0;j1<8;j1++)
				JTable table=new JTable(data1,Colheads);
				int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
				int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
				JScrollPane jsp=new JScrollPane(table,v,h);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.