| Author |
event handling
|
Altaf Ahmad
Greenhorn
Joined: Apr 24, 2002
Posts: 13
|
|
Hi! I had a conceptual question about Java event handling. When we implement event handling by extending classes or implementing interfaces, we end up having a different class handling events. How, then, is it possible to work with data (objects) of the class which is generating the events? For example, say I have a JProgressBar and a JTable as objects in a class. When a user clicks on a row in the table, the progress bar's value should reflect the new table row selection. To access both the objects, we need to work in the class containing both of them. If we extend the JTable class or implement a selection interface in a new class, then we don't have access to the progress bar any more! I'm sure I'm missing something or trying to do it the wrong way. Could anybody explain to me where I might be taking an incorrect approach (in the language or logically)? Thanks! Altaf
|
 |
Roy Ben Ami
Ranch Hand
Joined: Jan 13, 2002
Posts: 732
|
|
if i understand your question correctly my suggestion is this: first you can pass refernces to the new classes of the progressbar and the jtable so you can access both. second and even better is just to use inner classes or even annonymous ones so you can access all the variabls you got in your main class. create the event handling class (the listener) as an inner class inside the class you got the progrss bar and the jtable. hope it helps.
|
 |
 |
|
|
subject: event handling
|
|
|