• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

problem painting

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, that helps alot.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic