java - Calling repaint for specific JPanel in JFrame repaints also JDialog -
below small example describe
well, have simple jframe
jpanel
contentpane
repaint
swingworker
every 20 ms panel.repaint()
.
also, have jdialog
opened shows own graphics opengl (i use awtglcanvas
lwjgl
library) swaps buffers , repaint()
every time paint content (faster 20ms).
the big problem in way repainting jpanel
affects jdialog
meaning if remove panel.repaint()
(which have done) works fine! when have panel.repaint()
jdialog
shows strange lines have cut graphics in 2 , try move them no success. dont know if call flicker may problem.
public testframe(){ panel = new jpanel(){ protected void paintcomponent(graphics g){ //do painting jpanel here } } setcontentpane(panel); updatetime(); } public void updatetime(){ swingworker worker = new swingworker(){ @override protected object doinbackground() throws exception { while(stoptimer == false){ thread.sleep(20); if(isfocused() == true){ timer += 0.2f; panel.repaint(); } } return null; } }; worker.execute(); }
and here awtglcanvas.paint
method in jdialog contentpane
@override public void paintgl() { //do painting classic opengl swapbuffers(); //awtglcanvas built-in method, meaning cant control repaint(); // runs paintgl() again }
thanks in advance!
Comments
Post a Comment