I have a class that extends JFrame and pops up a window (frame). I successfully added a jpanel and a jscrollpane that uses that panel.
I have a Jbutton on the jpanel that uses actionlistener and will call repaint (or paintComponents, whichever you think is better) every time I click the button.
The problem is, what gets painted will get erased when I scroll over the painted material. The JButton stays and doesn't get redrawn, but the stuff that gets painted gets erased.
So my question is: How do I paint outside of the JViewport on a JScrollpane's panel?
I have been trying in vain, experimenting with the Graphics class methods such as Graphics.setClip()
and JViewport.setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE)
...
the setClip()
method in fact does the opposite of what I want to do. It limits the paintable area of the chosen component, when in fact I want to expand the area that gets painted - I want to paint (and keep painted) the area outside of the viewport.