|
-
May 13th, 2004, 09:36 AM
#1
Thread Starter
New Member
Help
I am trying to pass a variable in From a form to a class in Sun ONE studio
-
May 14th, 2004, 11:32 AM
#2
A form is a class too.
What do you mean by pass? If you're in the class' code and want to access a variable of the form you need a reference to the form and an accessor function for the member. If you're in the form's code and want to create an instance of the class and give it the variable, you need to pass it to the constructor. If you already have an instance of the class you could call a setter function for a property of class or pass it to individual methods you call.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 14th, 2004, 02:56 PM
#3
Dazed Member
What kind of variable is it also? Reference or Primitive? As CornedBee pointed out in his suggestion, if you are in the form code you can simply create an instance of the class and pass the variable via the class constructor. I usualy use this method which is somtimes refered to as Aggregation. I often use Aggregation when i need a class to be able to invoke a method back on the class that was passed in as a reference. For primitive values that need to be passed in and modified i just define setter methods within my class while keeping the class members private as to keep everything properly encapsulated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|