DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2003

    Passind Data between classes.

    Hi all.
    I am designing an application, that has a toolBar[object] running down one side, with various buttons on it.
    It also has a canvas[object], which is where the program will be drawing whatever.

    How I can pass paramiters from the toolBar[object] to the canvas[object], to say what button was last pressed.

    canvas and toolBar are both called from a workSpace class but NOT inherited.

  2. #2
    Join Date
    Oct 2004
    What I usually do in such cases is modify the constructor from both the toolbar class and the canvas class to accept an instance of the workSpace class (The calling object). This way you can perform callback method calls from the toolbar to the workspace. The workspace in turn has a handle to the canvas, and thus can relay the information on behalf of the toolbar.

    This is one of the easier ways to do it. You could also create your own action listener, instead of using the ones created by the gui editor of you IDE. This would allow you to directly do the relaying from there. but this is a little more complex.

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
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

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

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.