Java Reference
In-Depth Information
6. public SimpleGraphicsDriver()
7. {
8.
SimpleGraphicsFrame SGF = new SimpleGraphicsFrame();
9.
SGF.showIt();
10. }
11. public static void main(String[] args)
12. {
13.
SimpleGraphicsDriver sgt = new SimpleGraphicsDriver();
14. }
15. }
Exercises
5.1
Check and explain what happens if one omits the super -command in paint-
Component or if it is put at the end of paintComponent .
5.2
Add further graphic commands to paintComponent .Test what happens if
you draw outside the currently visible area. Resize the window.
5.3
A repaint of the GUI is initiated by the runtime system quite frequently. We
would like to see how often this occurs. To this end, define an integer variable
noOfRepaints in SimpleGraphicsPanel and set it to zero in the construc-
tor. Increment this variable in method paintComponent . Then its current
value is the number of calls to paintComponent . Add a command to paint-
Component which draws the value of noOfRepaints into the panel with
some explanation, for example, 'The number of redraws is'. Move and resize
the panel to see how many repaints are actually performed.
Search WWH ::




Custom Search