Archived

This topic is now archived and is closed to further replies.

Benzy54

[java] jsrollpanel

Recommended Posts

Benzy54    122
I have a frame with a jscrollpanel. The scrollpanel''s child is a panel with lines drawn on it. When it runs and i scroll down or sideways the lines become distorted and won''t get better until i resize the window. I know i could repaint. But what about image buffering. Could someone explain it to me.

Share this post


Link to post
Share on other sites
eboz    122
I''m not sure what you are trying to do here. It sounds like you are trying to scroll through a map, and you are rendering the entire map every frame. If so, that''s not really the best way to go about things. Look at some articles on the web dealing with Tile Engines. You should only Render what the user can see at once, and often not even that much (the dirty rectangle theory).

As for double buffering, I was of the thought that the Swing Library already took care of that. Repaint seems to be your only answer in this case.


Eboz

Share this post


Link to post
Share on other sites
buh    122
Well, you could try setDoubleBuffered(true). Also try all three viewport scroll modes to see which one works best. SIMPLE_SCROLL_MODE, BLIT_SCROLL_MODE or BACKINGSTORE_SCROLL_MODE. Use getViewport.setScrollMode() for that. I think BLIT will be the best. Not sure. Hope that helps

Share this post


Link to post
Share on other sites
Jim_Ross    122
Sounds like there''s a problem with mixing lightweight and heavyweight components. Try making everything a JComponent subclass; Frame -> JFrame, Panel -> JPanel. That could be the only cause of your image corruption.

Share this post


Link to post
Share on other sites