Prevent Java from redrawing JPanel content on refresh

I have a JPanel that contains many child components. By updating \ adding new components to the parent JPanel, I would like to prevent it from being redrawn, how can this be achieved?

+1


source to share


3 answers


Try RepaintManager.currentManager (component) .markCompletelyClean (component) . This will prevent reprogramming of the component. You may need to do this every time you add new components.



+7


source


setVisible(false)  

      

update



setVisible(true)

      

+2


source


you can try with help setIgnoreRepaint(boolean value)

, but this is a typical swing function that may or may not work (mainly because it depends on AWT, so you never know).

Otherwise, you can override the method paint

using a flag that simply returns the method instead of being called super.paint()

. (the actual override paintComponent

should be the right choice)

+1


source







All Articles