Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return Value from a class

Status
Not open for further replies.

alan2624

Programmer
Mar 26, 2002
16
US
I have a form in which I click on a button and a Calendar pops up. When a date is chosen, I want to place it in a field on the first form. It seems simple but can not seem to find the answer. Help.

Thanx
 
The answer IS simple.
Let's say your form is a class called MyForm. And the calendar is called MyCalendar.
All you got to do is make a constructor of Calendar which receives MyForm. Store this as parent, and when clicking in calendar you call some method of the parent.
Like this:
Code:
public class MyForm
{
   ...
   public void setDate(Date d)
   ...
}

public class MyCalendar
{
   private MyForm parent=null;
   ...
   public MyCalendar(MyForm parent)
   {
      this.parent=parent;
   }

   public void onClickBlabla()
   {
      ...
      parent.setDate(xyz);
   }
}

Something like that should work fine (it does for me)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top