File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes event handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "event handling" Watch "event handling" New topic
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: event handling
 
Similar Threads
JTable(!!!)
JRadioButton in JTable
jtable
JTable
JTable