File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes problem painting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem painting" Watch "problem painting" New topic
Author

problem painting

Derek Boring
Ranch Hand

Joined: Aug 15, 2006
Posts: 63
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.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
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.
Derek Boring
Ranch Hand

Joined: Aug 15, 2006
Posts: 63
Thanks, that helps alot.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

"Zero" -

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.

You can change your user name here.

Thanks! and welcome to the JavaRanch!


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem painting