For some reason, when this code is executed, it will sometimes draw the strings in the color set in the preceding setColor method (what it should be doing), but it will often draw it using textColor or some other color set afterwards instead. The colors drawn will vary almost every time it is executed.
The colors are static constants and are declared at the top of the class.
Question
dholmes13
For some reason, when this code is executed, it will sometimes draw the strings in the color set in the preceding setColor method (what it should be doing), but it will often draw it using textColor or some other color set afterwards instead. The colors drawn will vary almost every time it is executed.
The colors are static constants and are declared at the top of the class.
Any ideas what I'm doing wrong?
statistics = new GameImage(240, 300); statsG = (Graphics2D) statistics.getGraphics(); statsG.setColor(bgColor); statsG.fillRect(0, 0, 240, 300); statsG.setFont(new Font("Old English Text", Font.PLAIN, 16)); statsG.setColor(healthColor); statsG.drawString("Health", 0, 20); statsG.setColor(energyColor); statsG.drawString("Energy", 0, 40); statsG.setColor(expColor); statsG.drawString("Exp", 0, 60); statsG.setColor(textColor); statsG.drawString("Strength", 60, 80); statsG.drawString("Agility", 60, 100); statsG.drawString("Intelligence", 60, 120); statsG.drawString("Endurance", 60, 140); statsG.drawString("Luck", 60, 160); statsG.drawString("Base Attacks", 0, 200); statsG.drawString("Spirit Force", 0, 220); statsG.drawString("Elemental Bolts", 0, 240); statsG.drawString("-", 113, 200); statsG.drawString("-", 113, 220); statsG.drawString("-", 113, 240);Link to comment
Share on other sites
6 answers to this question
Recommended Posts