My class extended from DefaultTableModel
I try:
super.removeRow(...);
And
this.removeRow(...);
Why do they both work?
My class extended from DefaultTableModel
I try:
super.removeRow(...);
And
this.removeRow(...);
Why do they both work?
super
refers to the super (parent) type's implementation.
this
refers the the current type's implementation, if one exists, otherwise looks up the inheritance tree, ie. does the same as super
.
Depending on how your class extends DefaultTableModel
, they might be calling the same method.
not an answer, but this.whatever
can be pretty misspeled in most complex Swing GUI
super.removeRow(...);
And
this.removeRow(...);
should be (my view to avoid ....)
myTableModel.removeRow()
- e.g. ((DefaultTableModel) table.getModel()).removeRow(row);
or you override in XxxTableModel
public void removeRowAt(int row) {
Actually they are calling same method i.e. removeRow
in parent class for your case.
Only for the case when you decide to override removeRow
in your child class then you can make a call to super.removeRow()
like this:
@Override
void removeRow() {
// call parent class's removeRow
super.removeRow()
// rest of implementation
}