Constructor being called again?
- by Halo
I have this constructor;
public UmlDiagramEntity(ReportElement reportElement, int pageIndex, Controller controller) {
super(reportElement.getX1(), reportElement.getY1(), reportElement.getX2(), reportElement.getY2());
setLayout(null);
this.pageIndex = pageIndex;
this.controller = controller;
reportElements = reportElement.getInternalReportElements();
components = new ArrayList<AbstractEntity>();
changedComponentIndex = -1;
PageListener p = new PageListener();
this.addMouseMotionListener(p);
this.addMouseListener(p);
setPage();
}
And I have an update method in the same class;
@Override
public void update(ReportElement reportElement) {
if (changedComponentIndex == -1) {
super.update(reportElement);
} else {
reportElements = reportElement.getInternalReportElements();
if (components.size() == reportElements.size()) {
if (!isCommitted) {
if (reportElement.getType() == ReportElementType.UmlRelation) {
if (checkInvolvementAndSet(changedComponentIndex)) {
anchorEntity(changedComponentIndex);
} else {
resistChanges(changedComponentIndex);
}
return;
}
}
..................goes on
When I follow the flow from the debugger, I see that when update is called, somewhere in the method, the program goes into the constructor and executes it all over again (super, pageIndex, etc.). Why does it go to the constructor :D I didn't tell it to go there.
I can make a deeper analysis and see where it goes to the constructor if you want. By the way, changedComponentIndex is a static variable.