MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

COMPUTER GRAPHICS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
By default, graphics coordinates in Java have the origin (0, 0) in the ____ corner of the drawing area.
A
upper-left
B
upper-right
C
lower-left
D
lower-right
Explanation: 

Detailed explanation-1: -coordinate system in Java. (0, 0) means the top, left corner of the applet window.

Detailed explanation-2: -By default, Java 2D uses the same coordinate system as AWT. The origin is in the upper-left corner of the drawing surface. X coordinate values increase to the right, and Y coordinate values increase as they go down. When drawing to a screen or an off-screen image, X and Y coordinates are measured in pixels.

Detailed explanation-3: -So, you would say simply “g = getGraphics()". This gives you a graphics context for drawing in the component you are writing. If g is a graphics context that you’ve obtained with the getGraphics() methods, it is a good idea to call the method g. dispose() after you have finished using it.

Detailed explanation-4: -paintComponent(Graphics g) is a method inherited from JComponent (Note that paintComponent should have Override anotation), it is part of the draw system of the GUI. It’s invoked from Java Swing Framework to ask for a Component to draw itself on the screen.

There is 1 question to complete.