Given a graphics object g, write a few lines of code to have that graphics objec
ID: 3543454 • Letter: G
Question
- Given a graphics object g, write a few lines of code to have that graphics object draw a green circle (not filled in) that has a diameter of 200 pixels.
- Given a graphics object g, write a few lines of code to draw a blue rectangle (filled in) with its upper left corner at position 88, 44 with a width of 150 and a height of 200.
- How would you use the Graphics class to draw a line between the points 50,100 and 25,75? Give the Java statement needed.
- Describe the graphical coordinate system in Java. Where is the origin? What units apply to the x,y coordinates?
- How would you create a Monospaced font of point size 16 that is italic? Give the Java statement needed.
- How do you specify that the color red will be used as fill when using the Graphics class? Give the Java statement needed.
- What does invoking the base class paintComponent method accomplish?
- What is the paintComponent method? How is it used in Java graphics? How does a program intentionally cause the paintComponent method to execute?
- What window events can a program handle? Explain the difference between the WindowListener interface and the WindowAdapter.
- What interface does an application need to use if it wants to get updates on the current position of the mouse cursor as the mouse is being moved? How does the program get the x,y coordinates of the mouse cursor?
Explanation / Answer
Dear,
Hello,
You have posted multiple questions(>7). Replying you with 2 answers. Please do post remaining new posts so that we can help you...
1)
//Set color
g.setColor(Color.green);
g.drawOval(10,10,100,100);
2) //Set color
g.setColor(Color.green);
g. fillRect(88,44,150,200);
Hope this will help you..
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.