I have a JFrame that contains a JPanel (tbox), and a JScrollPane (vPort) which displays the contents of another JPanel (view). The problem is when I draw on 'view' tbox does not repaint and the scrollbars on vPort do not repaint, they show whatever is behind the JFrame. The drawing is done in the JFrame's 'paint' event. I've tried calling the 'repaint()' methods for 'tbox' and 'vPort' at the end of the event and the componets repaint, but then it doesn't show what is drawn in view.
When no repaints are called:
When 'tbox.repaint()' is called:
When 'vPort.repaint()' is called:
When both are repainted:
Life is 10% what happens and 90% how you react to it.
Attitude is everything.
The drawing is done in the JFrame's 'paint' event. This is not the recommended way to draw in a top–level container. Better to use a JPanel or JComponent that is dedicated to graphic display. Here is an example.
Welcome to the JavaRanch! We don't have many rules around the ranch, but we do have a policy on displayed names... Please adjust your displayed name to meet the JavaRanch Naming Policy. User names cannot be obviously fake and must consist of a first name and a last name.