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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Handling GUI event separately." Watch "Handling GUI event separately." New topic
Author

Handling GUI event separately.

T James
Greenhorn

Joined: Aug 09, 2012
Posts: 2
Good day to all, I'm hoping anyone can give me an idea on how to solve my little problem.

I have a class to handle all GUI drawing/updating but I want to have another class to deal with
all event handling and I am confused on how to proceed.



So basically, I have a main class that calls the EventHandler start() then the EventHandler
should take care of everything. The problem is that the two loop around creating each other
which I suspect is due to them creating new instances of each other. However, I am confused
as to an alternative of handling this.

Anyone care to give hints on how I should proceed with this?
Any words to point me in the right direction is much appreciated. Thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18115
    
    8

The EventHandler class shouldn't create a new ScreenHandler object. It needs a reference to the existing ScreenHandler object, doesn't it? So provide EventHandler with a constructor which accepts and stores a ScreenHandler reference, and have ScreenHandler pass itself to that constructor.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Handling GUI event separately.
 
Similar Threads
ActionListener code. Problem deciphering of
Problem with Inner Classes
changing font style and size
Event Handler for current menu selection.
Find jLabel reference to update (from array of jLabels)