This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Are there any questions based on Painting in the real SCJP exam? (on drawString, drawXXX) Is there a possibility that I could get a question like this in the exam? Has anybody got a similar question in the exam? Q48 Marcus Green Mock 1 You have created a simple Frame and overridden the paint method as follows
What will be the result when you attempt to compile and run the program? 1) The string "Dolly" will be displayed at the centre of the frame 2) An error at compilation complaining at the signature of the paint method 3) The lower part of the word Dolly will be seen at the top of the frame, with the top hidden. 4) The string "Dolly" will be shown at the bottom of the frame. Answer and Explanation -
3) The lower part of the word Dolly will be seen at the top of the form The Second parameter to the drawstring method indicates where the baseline of the string will be placed. Thus the 3rd parameter of 10 indicates the Y coordinate to be 10 pixels from the top of the Frame. This will result in just the bottom of the string Dolly showing up or possibly only the descending part of the letter y.
- Write code using component,container,and LayoutManager classes of the java.awt package to present a Graphical User Interface with specified appearance and resize behavior,and distinguish the responsibilities of layout managers from those of containers - Write code to implement listener classes and methods,and in listener methods,extract information from the event to determine the affected component,mouse position,nature,and time of the event - State the event classname for any specified event listener interface in the java.awt.event package
As you can see on the first bullet, the emphasis is put on Layoutmanagers and how they handle components when containers are resized. That means you should know how a container will look in respect to its contained components when resized. No painting at all. [ March 19, 2002: Message edited by: Valentin Crettaz ]