Archived

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

[java] canvas in a jframe

This topic is 5504 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

Ok, in the past, all of my java game programming has been done in applets. So now I need to plot some points but it has to be an application. I was thinking about just creating a canvas, drawing on it, and then adding it to a jframe. The problem is that I don''t know much about canvas'' Do I have to make it a thread and have a repaint() every few seconds?

Share this post


Link to post
Share on other sites
I think it depends on what you are doing. You can create a thread (or a Timer) object to ''repaint()'' the canvas at intervals. The best way of doing it would to repaint the canvas only when you need to, everytime the canvas changes, repaint it to update to the screen.

Seeing that you have create applets before, you might be used to repainting the canvas continously (as in an applet). This is done easily by creating a javax.swing.Timer object to 0 intervals (update all the time) to repaint the canvas by calling repaint().

Share this post


Link to post
Share on other sites