Possible Duplicate:
Using Graphics2D to overlay text on a BufferedImage and return a BufferedImage
My Question is how to draw a String permanently to an image.
When I draw the String and then refresh the image the String is gone on the display.
Possible Duplicate:
Using Graphics2D to overlay text on a BufferedImage and return a BufferedImage
My Question is how to draw a String permanently to an image.
When I draw the String and then refresh the image the String is gone on the display.
..how to draw a String permanently to an image.
If you mean a BufferedImage then it is simple.
Graphics or Graphics2D instance from the image.The job is done. To display the image, add it to a label.
If you have an Image instance as opposed to a BufferedImage instance, create a buffered image as large as the original image, then paint it to the graphics instance before step 2. (draw the string) above.
In order to make the text always show on top of the image, place your drawString call inside paint(Graphics g)
It would be helpful if you posted some of your code, but I think you are probably calling drawString from the wrong place. Now if you also want to save the image with the text on top, that is another matter. I would probably use javax.imageio.ImageIO.write for that.