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);
}