java - Why is drawing on JFrame so much slower than on a JPanel? -
my question why same swing-custom-painting routine 16 times faster when drawing on jpanel compared directly on jframe? double-buffering? can't be, surely?
background: had problem custom-painting not being refreshed when jframe unobscured (especially having been partially obscured). after searching decided bite-the-bullet , figure-out how wire subclass of jpanel bluddy-netbeans-form-designer form.
for in same situation: in netbeans need create new standard class (not jpanel form) happens extend jpanel, , manually code there-in (no gui designer, good-ole-days, sigh). add standard jpanel form, set it's size; right-click , select "customize code" , select "custom creation" in combo-box... creates new javax.swing.jpanel substitute subclass thereof.
so... allowed me "do properly" , paint on component, instead of directly on form. also, panels-key-listener neater solution hi-jacking frames key-event-dispatcher.
anyway, profiler says same custom-painting-code executes 16 times faster in jpanel's paintcomponent() apposed jframe's paint()... , wondering if please explain why.
thank in advance. keith.
edit: question based on misinterpreted metrics. profiler not include/report jpanel's paintcomponent() method in awt-eventqueue thread, where-as baseline profile include jframe's paint(). should have looked more before asking silly question. bad.
jframe top level container extending aw.frame needs native resources drawing whereas jpanel swing component rendered ui thread itself.
Comments
Post a Comment