Hi, I searched through the site for drawString discussions and none of them gave a clarification to the problem I am experiencing. I am creating a graphics pane in my servlet and then eventually write the graphics pane into a JPEG. Can you please tell me what I have to do to get the remainder of my tile's labels to display? currently it will only display the Tile(0,0) label.
If this were my problem, the first thing I would do is move all of the imaging code out of the servlet and put it into a plain old java object (POJO). Put the code that creates the image in a method that returns a stream.
Then I could test this from the command line (have the main method write the outputstream to a file) and insure that the code works outside of the servlet environment. Once I got it working, then I would attempt to call it from a servlet and stream the results to a browser.
Also, it looks like you've got some non-final instance variables:
Whether you follow the last piece of advice or not, you'll want to make sure you understand the implications of using instance varaibles in a servlet or you could end up with a lot of threading problems.
Sure, I can move the code out of the servlet and test it outside of there -- one thing is that the variables you have indicated are not used in the code, but I do understand the implications of using them in a servlet b/c they are not thread-safe.
OK Here's the problem, I have used this methodology to create an image already in this very servlet that *did* use those variables and was able to create multiple strings of text on the encoded image.
Please if you would be able to take another look at this code and give me a deeper understanding of the issue that I see. Moving the code into a POJO will not change the order in which it is executed in this case. I believe that the problem has to do with layering somehow, the way that I am adding new tiles to the 2d panel, but I was unable to find any reference to this layering issue in the documentation for the drawString method or any of the other 2d graphic functionality.
One of the reasons to pull the code out of the servlet is to separate the servlet issuses from the model (in this case imaging) issues.
I'm guessing that your issue is probably not even related to servlets and would do better in Other Java APIs where you might actually get someone with graphics experience to read it. Moving the code out of the servlet would confirm this.