Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clipping question

 
J Wallace
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having a problem with clipping bounds not being what I expect them to be. I must not fully understand what's going on. Here is a simple example to illustrate the problem:



In the code above, java.awt.Rectangle[x=0,y=0,width=98,height=144] is initially printed. This seems like a reasonable clip. However, when I scroll down one unit, I get java.awt.Rectangle[x=0,y=144,width=98,height=1]. What is happening here? I was expecting to see something like java.awt.Rectangle[x=0,y=1,width=98,height=144]. Also, if I then scroll back up one unit, I get java.awt.Rectangle[x=0,y=0,width=98,height=1]. Why is it not back to the original clip?

Can someone please explain what's going on? Thank you.
 
Rob Camick
Ranch Hand
Posts: 2555
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When scrolling in a viewport you don't need to repaint the entire component, only the part that wasn't visible in the viewport before.

So the first time you need to paint everything.

When you scroll down 1 pixel you only need to paint the 1 pixel line at the bottom of the viewport.

When you scroll up 1 pixel you only need to repaint the 1 piexl line at the top of the viewport.
 
J Wallace
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. This makes perfect sense now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic