Jump to content
  • Advertisement


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


[java] Repaint in Java 2

This topic is 6775 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just noticed that in Java 2 the painting doesn't work in a java.awt.Component subclass with the following code:
// Somewhere in the code we get the graphics object

// Draw the new frontbuffer to the screen
m_componentGraphics.drawImage( m_frontBuffer, 0, 0, null );
But for some reason if I make my graphics engine a subclass of java.awt.Canvas everything works again. The above code works just fine in Java 1.1 within a Component subclass. It smells like something has been changed in the AWT's peer system between Java 1.1 and Java 2. Does anyone know what causes this behaviour? Edited by - javanerd on 4/4/00 2:10:40 PM

Share this post

Link to post
Share on other sites
java.awt.Component doesn''t have a drawImage method. If those two lines are your actuall code, then it is simply a matter of doing
Graphics m_componentGraphics = m_component.getGraphics();
The graphics class does not have a getGraphics() methods.

If that is not really your problem, the only thing I can think of is that Canvas'' paint() overrides Component''s paint. There might be a difference there. Also, try java.awt.Component.updateImage() instead of java.awt.Graphics.drawImage(); That might do the trick.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!