Im building a program that lets you enter the course name, course time and course day and sets the course name in a one week setting and this is the code i tried to use to remove a course from the jtable by simply inputing the name of the course and having algorithm go through the table until it finds the cell with the same course Name.
JButton btnRemoveCourse = new JButton("Remove");
btnRemoveCourse.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
String courseName = JOptionPane.showInputDialog("Enter name of course you want to remove");
int i = 0,j = 0;
while(table.getValueAt(i, j) != courseName)
{
i++;
j++;
}
table.setValueAt("", i, j);
}
});
I basically want the user to enter the course name that they want to remove and then search for that course name in the jtable and set that cell to empty.