Results 1 to 3 of 3
  1. #1
    dvd_gonzales is offline Member
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Question i need help with clases

    hi.


    im creating a gui app in witch i create a class call customer_main ( my classes are JFrames )

    form customer_main i call another class call order_details .

    when i call order details i hide the customer_main class

    now the problem is that i canot call the customer_main from withing order_Details with out creating another object.

    i have to work with the same object from customer_main.

    i really need help if you can help me any way i thank you in advance

    ps. sorry for my tipos. im just learning english.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,652
    Blog Entries
    7
    Rep Power
    21

    Default

    If two objects A and B need to know each other they can pass themself to the other object as a parameter of another method:

    Java Code:
    public class A {
       private B b; // we need to know it
       // introduce a B to this object A:
       public void iAmAB(B b) { this.b= b; }
       ...
    }
    
    public class B {
       public B(A a) { // B knows A because it passed itself as a parameter
          a.iAmAB(this); // show yourself
       }
       ...
    }
    kind regards,

    Jos

  3. #3
    dvd_gonzales is offline Member
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Smile thank you for you quiqk reply

    JosAH thank you for you help!!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •