문제

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);
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top