CSS font stacks & developer FAQs with Web standards
Site navigation below

One of hundreds of answers available with our premium content service.

Part answer

A: When you have a method that takes an object as an argument, you must pass an object of the specified type in the method call. There is no Graphics method that accepts a Rectangle to draw, nor a Rectangle method that accepts a Graphics object to render to.

Since Graphics is an abstract class, you must obtain a concrete implementation. You can then use its drawRect(int x, int y, int width, int height) method to draw an outline of your rectangle, as below.

… full answer hidden

Click for full answers

Premium members click below for full answer
How do I draw a Rectangle on a Graphics instance?

Home · Web fonts · Font stacks · FAQs · Java · CSS · Javascript · HTML · Site manager