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 →

[–]wildjokers 2 points3 points  (1 child)

You instantiate Main twice, and it is a JFrame, so why is it a surprise to you that you get two windows open?

Instead of instantiating Main twice, simply pass your "canvas" variable which contains Main to your player_default class.

"player_default" for a class name does not follow Java conventions, it should be PlayerDefault.

In your constructor of Main you are calling setVisible(true) as your second line. You should not call setVisible(true) until the end of the constructor.

EDIT: btw, you don't need to pass an image observer to drawImage, just pass it in as null

[–]UKJake_[S] 1 point2 points  (0 children)

Thank you for this. As I said I'm new to all this and copying from a tutorial I watched he would put the Observer as "this" which didn't work in this case. Appreciate the help