2

I was trying to create a rectangular image where will be 2 things.

  1. A label (100% width and 20% height)
  2. A Text Area (100% width and 80% height)

So lablel will be at top and text area will be at bottom

so I tried to create a JFrame and place both components there. Then I am creating its image with JFrame.createImage(width, height) and in last I used ImageIO.write(). but problem was, There was some extra blank space around the components in Image. When I tried to set its bound then it create an exact image but this image works perfectly on Windows but it doesn't work on Mac. Any idea why?

Is there also another easy way where I can achieve this. I've spent 2 days but couldn't found any solution.

Please advice

Thanks in adnvace

2
  • It's usually not a good idea to try and create images of text. Is it strictly necessary for you to do so? Commented Dec 10, 2010 at 23:57
  • Post your SSCCE (sscce.org) demonstrating the problem. Commented Dec 11, 2010 at 0:12

1 Answer 1

1

Rendering using Swing components is very versatile, but the user interface delegate for each component varies by platform. Similarly, font metrics also vary by platform and vendor. If you need very fine control over the placement of text, you can access the graphics context's font metrics as seen in this example, and you can mitigate aliasing as shown here.

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.