开发者

Create image file with java

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 advic开发者_运维问答e

Thanks in adnvace


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜