Accessing an object from another Object


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Accessing an object from another Object

  1. #1
    Join Date
    Feb 2008
    Location
    Tompkins County, NY, USA
    Posts
    20

    Accessing an object from another Object

    Hey Guys,

    I have an tab control that dynamically generates a group of user controls. It is my goal that when a jLabel is clicked on one of those controls that it be removed from the tab control.

    However, it seems that it is not possible to pass an object into another one using Java. Is there anyway I could access the upper-level control to remove this object from it's collection?

    Thanks for any help!

  2. #2
    Join Date
    Jul 2005
    Location
    SW MO, USA
    Posts
    299
    to pass an object into another one
    You can pass a reference to one object to code in another object several ways:
    via its constructor
    via a method
    via a global (public static)

    Can you explain the problem a bit more. These are very simple concepts.

  3. #3
    Join Date
    Feb 2008
    Location
    Tompkins County, NY, USA
    Posts
    20
    Actually, after much research and trial and error I discovered that using "static" variables was the only way to do this. Java has no pass by reference, when an object is passed, it is passed with only default values. This is documented in Sun Microsystems documentation.

    However, I am fairly new to Java and know the basics and not much else, though I am learning very quickly as I go along. Your help is appreciated though.

  4. #4
    Join Date
    Jul 2005
    Location
    SW MO, USA
    Posts
    299
    when an object is passed, it is passed with only default values
    The values in an object are not changed to "default values" when a reference to that object is passed via a method. If you add a println() to show what is in an object just before calling a method and in the method println() the same variables that will show the values to be the same. The contents of an object is not changed.

Similar Threads

  1. MAPI Logon failure accessing Outbox object
    By ShadowKatmandu in forum ASP.NET
    Replies: 0
    Last Post: 10-31-2008, 04:49 PM
  2. Accessing Servlet object from JSP
    By thanvi in forum Java
    Replies: 1
    Last Post: 06-07-2005, 11:55 PM
  3. Replies: 0
    Last Post: 05-27-2003, 12:12 PM
  4. Replies: 1
    Last Post: 10-24-2000, 05:48 PM
  5. Accessing OLE object in an ACCESS database
    By Sam Avella in forum VB Classic
    Replies: 2
    Last Post: 07-14-2000, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center