I am trying to paint a cube on a JFrame.
Sounds simple, but lags a lot. The 7th and 8th lines usually flash pretty bad.
here is the code:
if someone can give me a hint or two on how to stop this lag from occurring, that would be great :D.
Originally was for Applet, but i wanted it to execute through a .jar file.
Also, any way to add an Applet to a JFrame?
I tried doing: add(new Rotational()); //name of JApplet it is based off of.
Thanks, Fire
Does this variant work to your expectation? There are a number of changes which I did not bother to document (as I was ‘just playing’ with the code). Do a diff. to reveal the extent and nature of the changes.
It shows no lag or rendering artifacts here at 700×700.
Good idea converting an applet to something more sensible, but note that an applet can (and usually should) be packed into a Jar.
This is possible, relatively easy with this code (barring mixing Swing (
JFrame) & AWT (Applet) components), but not the best way to go. It is better to create a hybrid like (for example) the subway applet/application.By moving the custom rendering from the frame to a
JPanel, the code has been partially transformed into a hybrid, since the panel can be added to a frame or applet (or window or dialog, or another panel or..).