Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JTable problem - overlap

843807Jul 17 2010 — edited Jul 17 2010
I have made a database search program, where I display the searched items in a JTable, using vectors. I have successfully created the table along with the vectors, and when i press the search button(functioned to display the table when search is successfull), i see the table with the entries.

However, when i press the search for a second or third time, i still see the results, but if i click anywhere on the 'columns' of the JTable, my current search is overlapped by the first search i made. I feel this is because all my tables are overlapping each other everytime i press search

I have put the JTable in a ScrollPane, and I do not have a Table Model, since i am not familiar with the topic as yet.

My code :
			Vector data = new Vector();
			Vector columns = new Vector();

			JScrollPane scrollPane;
			JTable table;
                        .............. 
                        ..............
				columns.add("Name");
                                 ...... 
                                ......   
				data.add(whatever_my_data_is)
				if(condition_for_successfull_search)
				{
					JOptionPane.showMessageDialog(null,"Record Found","Student Registration Program",1);
					
			         	table = new JTable(data,columns);
			        	scrollPane = new JScrollPane(table);

					scrollPane.setBounds(2,400,590,75);
					panel.add(scrollPane);

				}
				else 
				{
					JOptionPane.showMessageDialog(null,"Record Not Found","Student Registration Program",2);
				}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 14 2010
Added on Jul 17 2010
1 comment
202 views