Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling GUI event separately.

 
T James
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21316
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic