posted 12 years ago
ok, i got this working.
here is the code i used
but i have couple of questions.
I am following "Head first Java" book.
it says that when a repaint() method is called , it calls paintComponent() method for every widget added to the frame.
My questions are
(1) is it not a overhead when a repaint() method is called , it calls paintComponent() method for every widget added to the frame. Although it is clear here that only Panel(here drawPanel) widget has provision of paintComponent() method being called and the button widget added to the frame here can not call paintComponent() method.
(2) My second question is .. when i executed this programme, how come at the first go itself the panel having colured oval is shown. where this should come only when the "Change Colour" button is clicked that is when an event ocurs then only the actioPerformed function is called and then repaint() function is called on the frame.
i hope i am clear to you guys ?