开发者

Java swing rendering optimizations

I understand that Java's native swing UI elements do a number of rendering optimizations so it performs better. That said, if I had a customized JPanel (meaning, I've overriden its paintComponent method):

  1. Will rendering optimizations be performed still (as I would hope)?
  2. Can I manually tell its parent container when to repaint the JPanel? Said differently, can I freeze the re-rendering of the JPanel until explici开发者_StackOverflow中文版tly told so?
  3. If so (#2), can I tell it to repaint only a specific portion of the JPanel (smart painting, I think its called...)?
  4. And finally, will re-rendering the JPanel be able to handle transparency, rounded corners, or other non-rectangular shapes for the JPanel? (meaning it will re-render elements underneath the JPanel, I suppose)

If not, are there alternate techniques for faking it? (preferrably just a link to a source/reference I can read from)


To speed up the rendering you can use BufferedImage. Render your content once on the image's Graphics and use image instead of rendering all the content.

To render portion of panel use Graphics' setClip()/getClip() check which region has to be refreshed and draw only portion.

TO draw non rectangular object use the same setClip setting necessary Shapes.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜