Link to home
Start Free TrialLog in
Avatar of malcx
malcx

asked on

inform calling object

Very rough example set up...

class A {
.
.
  B b = new B(123);
  // Add a listener here? so that when b.myID alters something happens.
.
.
}

public class B{
  int myID = 0;

  public B(setB){
    myID = setB;
  }

  public void setB(){
    myID = 312;
  }
}

How do I code so that when the value of myID changes in the instance of B then a method is called in the generating object of class A?

I'm guessing I'll need to add a listener of some kind to class A and a method to handle this in B???

Cheers,

Mal
ASKER CERTIFIED SOLUTION
Avatar of imladris
imladris
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of malcx
malcx

ASKER

Great thanks!
Last time I programmed in Java I basically used it procedurally. I'm just undertaking another large project (after about 18 months spent with other languages...) and knew this'd be fairly simple.

Thanks again,

Mal
Avatar of malcx

ASKER

Maybe I was a little hasty...
The code I'm currently working with is creating an instance of B from main() and as such won't let me use the non-static "this"...
???
Mal
Avatar of malcx

ASKER

OK have fixed now,cheers