Ask coding questions

← Back to all posts
Getting text on window working
hawlitza (0)

My text isn't showing up on my window. Unsure how to fix the error.
Assistance appreciated.

Comments
hotnewtop
SixBeeps (5036)

You never defined getlabel(), but used it on line 25 of MyGame.java

Because of this, it errors out before it has a chance to render the text.

hawlitza (0)

@SixBeeps So show I just comment it out? Or what should I replace it with?

SixBeeps (5036)

@hawlitza Well, it depends. What did you intend for getlabel() to do? If you don't know, I'd remove it.

hawlitza (0)

@SixBeeps I just wanted to print text on the screen, but I'm a beginner so I'm not fully sure what I'm doing.

SixBeeps (5036)

@hawlitza In that case, go ahead and get rid of line 25 all together.

hawlitza (0)

@SixBeeps Then how do I add text to window?

SixBeeps (5036)

@hawlitza You already do that by calling window.add() on line 37

SixBeeps (5036)

@hawlitza I think maybe the positioning is off

hawlitza (0)

@SixBeeps I think you're right. Do you know how I'd go about fixing it?

SixBeeps (5036)

@CodeLongAndPros No, since both class files are in the same directory you don't have to explicitly import it.