Unknown behaviour of interface TableModelListener

Hi,

I don抰 succeed to implement interface TableModelListener in an inherited class of JTable.

import java.awt.event.MouseEvent;

import java.awt.event.MouseListener;

import java.awt.event.MouseMotionListener;

import java.util.Vector;

import javax.swing.JTable;

import javax.swing.event.TableModelEvent;

import javax.swing.event.TableModelListener;

class ContrTabextends JTableimplements MouseListener, MouseMotionListener, TableModelListener{

private Object target=null;

public ContrTab(Vector rows, Vector colHead){

super (rows, colHead);

super.addMouseListener(this);

super.getModel().addTableModelListener(this);// this instead of super doesn't change anything

}

//public static void main(String[] args) {}

publicvoid mouseEntered(MouseEvent me){

target = me.getSource().getClass().getName();

System.out.println("mouse moves over " + target);

}

publicvoid mouseClicked(MouseEvent me){}

publicvoid mouseExited(MouseEvent me){}

publicvoid mousePressed(MouseEvent me){}

publicvoid mouseReleased(MouseEvent me){}

publicvoid mouseDragged(MouseEvent arg0){}

publicvoid mouseMoved(MouseEvent arg0){}

publicvoid tableChanged(TableModelEvent x){

System.out.println("reaction of tableChanged-method because of " + x);

}

}

1) What astonishes me first:

The compiler even doesn抰 complain when I omit the TableModelListener method

搕ableChanged?inside this class after adding this interface.

2) What happens adding the tableChanged method

The table (i.e. the instance of this inherited class) isn抰 constructed anymore by the calling class

Who抯 got answers to 1) and 2)

Thanks

[3513 byte] By [DeutscherMichela] at [2007-10-2 18:46:01]
# 1
1) JTable implements TableModelListener and therefore has a tableChanged method.2) Because you have overloaded the tableChanged method, the one in the JTable class isn't being called. Try calling super.tableChanged in your tableChanged method.
BaltimoreJohna at 2007-7-13 20:08:35 > top of Java-index,Security,Event Handling...
# 2

Thanks for your answer, but I'm not sure if I've got it right:

The syntax of tableChanged is

public void tableChanged(TableModelEvent e)

My code:

public void tableChanged(TableModelEvent x) {

System.out.println("reaction of tableChanged-method because of " + x);

}

and that's how I made it, I didn't change the signature means I didn't overload it.

So what do you mean?

Kind regards

DeutscherMichela at 2007-7-13 20:08:35 > top of Java-index,Security,Event Handling...
# 3
Sorry, I meant override. Your version of the method overrides the parent class's implementation of the method.
BaltimoreJohna at 2007-7-13 20:08:35 > top of Java-index,Security,Event Handling...