i searched google and found the following bit of code in a post that was made about 2 years ago. surprisingly it was not purged off the newsgroup it was located on. chalk another win for google. tell me what you think. yes it is a good way to do it, or no it isn't and why.
Code:
Graphics x = getGraphics();
x.clearRect(0,0,400,400); //400 X 400 (frame size)
again what i'm trying to do is erase the frame i'm drawing using a graphics object and with graphic methods (drawOval() & drawLine()). again thank you for the help. on the java board, i didn't get much assistance at all.
btw the following doesn't work in my code for some reason.
Originally Posted by
Perspective
myFrame.getContentPane().removeAll();
i'm extending jframe and using the inharitence. i executed the code with
Code:
getContentPane().removeAll();
and nothing happened
another fu question
Originally Posted by
Dante Shamest
Also, I think it is widely accepted that drawing directly on a JFrame is bad form. You should do your drawing on a derived JPanel class, and use it as the JFrame's content pane (using setContentPane()).
why is it bad form? can you draw to a content pane similar like to a jframe?
i have attached my code as .txt for comments on how to fix the bad form.
please forgive the horrible commenting. I haven't finished the project yet.