Results 1 to 4 of 4
Thread: event handling between classes
- 03-24-2010, 10:39 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 90
- Rep Power
- 0
event handling between classes
I have an issue involving event handling between classes.
I have a main class that creates a series of panels within a card layout. There are a few buttons that control movement through the cards.
One of the panels is created from an object created from another class. On this panel are a series of buttons.
I'd like to be able to click a button on this panel and move a different card (panel).
Is it possible to access the event handler in the main class from the panel with the button in question created from another class?
Or must I simply declare the buttons in the main class? (This would make the main class rather cumbersome.)
-
You probably don't want to declare the buttons in the main class. You might want to look into using an MVC pattern -- Model View Controller -- where the button's actions are part of the Controller class(es).
- 03-25-2010, 02:00 AM #3
To expand a bit on what Fubarable said... Typically, view components generate events. These components provide some form of addListener() methods so that controller components can create event listeners and add them to the view components. This provides a means for view components to alert controller components when events occur, without the view components having to know anything about the controller components.
So, all your buttons would be view components. Your view containers must provide a means for the controller components to add event handlers to the individual buttons.The Java Tutorial. Read it.
- 03-25-2010, 12:38 PM #4
Member
- Join Date
- Nov 2009
- Posts
- 90
- Rep Power
- 0
Similar Threads
-
Event handling... help?
By kevzspeare in forum New To JavaReplies: 2Last Post: 04-04-2009, 08:46 PM -
Event handling in JSF
By java08 in forum JavaServer Faces (JSF)Replies: 0Last Post: 03-24-2009, 06:42 AM -
rmi and event handling
By darkhorse in forum Advanced JavaReplies: 0Last Post: 03-15-2009, 08:20 AM -
SWT Event Handling
By Java Tip in forum Java TipReplies: 0Last Post: 12-30-2007, 12:21 PM -
Event Handling
By luisarca in forum Sun Java Wireless ToolkitReplies: 5Last Post: 05-07-2007, 06:05 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks