[java] canvas in a jframe

Started by
0 comments, last by Chaucer 21 years, 5 months ago
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?
Thanks!
Advertisement
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().

This topic is closed to new replies.

Advertisement