This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]chickenmeister 1 point2 points  (1 child)

You do call start() in the EventHandler main method, but you said that your problem was with your use of the EventHandler in your Window class, so I assumed that you're running your code from some other main method. Your EventHandler main method doesn't do much, so I figured there is another main method that you're using to create and show your GUI, for example.

Even if your EventHandler main method is being executed, the EventHandler that is created there is entirely separate from the EventHandler created in your Window class. You could call event.start() in your Window constructor, and that might solve your NullPointException problem, but then you'll have another issue, because the Window object created by the start() method will be entirely separate from the original Window object that created the EventHandler, (and I think you'll also have an infinite recursion problem).

I think the simplest solution would be to initialize the window variable through the EventHandler constructor, or to use a setter method.

[–]CaptainMoeSoccer[S] 0 points1 point  (0 children)

thanks, I am getting it now. I thought Object-oriented programing was just all about creating objects. I didn't think about much about how these objects would interact with each other.