-
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.
-
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
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|