Passind Data between classes.
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.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL