Question

This is what 'new' button does in my entry form, in addition to this, i want it to remove all displayed data from JTable. How can i do that?

   saved = false;
   txt_ipath.setText(null);
   txt_md_by_p.setText(null);
   txt_model_p.setText(null);
   txt_p_date.setText(sdf.format(date));
   txt_p_price.setText(null);
   txt_p_qty.setText(null);
   txt_s_price_p.setText(null);
   txt_vouchdate_p.setText(sdf.format(date));
   txt_vouchno_p.setText(null);
Was it helpful?

Solution

Assuming you are using a DefaultTableModel for your JTable you can just use:

model.setRowCount(0);

Or, if you are removing a row of data you can use:

model.removeRow(...);

any changes to the data should be done via the model.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top