2

I'm trying to use drawString to draw a string that says game over, but it wont work. earlier in the code it works fine but for some reason it stops working.

Code(only the part that doesn't work):

private static void end(Graphics g) {
    g.setColor(BG);
    g.fillRect(0, 0, 900, 900);
    g.setFont(new Font("TimesRoman", Font.PLAIN, 40)); 
    g.drawString("GAME OVER!!", 10, 30);
}
4
  • what is the variable BG? Commented Feb 19, 2015 at 21:30
  • 1
    An out of context code block isn't enough to diagnose your problem. You'll need to provided a runnable example which demonstrates your problem Commented Feb 19, 2015 at 21:32
  • 1
    You could be drawing with same color as the background. Commented Feb 19, 2015 at 21:32
  • 1
    The color of the text is the same as the background... Commented Feb 19, 2015 at 21:33

1 Answer 1

2

You need to set the color to something besides BG for the String to show.

private static void end(Graphics g) {
    g.setColor(BG);
    g.fillRect(0, 0, 900, 900);
    g.setFont(new Font("TimesRoman", Font.PLAIN, 40)); 
    g.setColor(FG)  // Here
    g.drawString("GAME OVER!!", 10, 30);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.