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?
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.
setVisible(false)
update
setVisible(true)
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)