Problem in generating the border of a rectangle in Java?

graphics, java, java-2d

Solution

How about doing both? Draw the filled rectangle first and then draw the outline one over the top.

Problem

I am using java.awt.geom.Rectangle2D.Double class to generate a rectangle. I want to generate a rectangle which is filled with a color (say green) and have a border (outline). Now the problem is if I call ``` g2.draw(new Rectangle2D.Double(....)); // g2 is an instance of Graphics2D ``` then it doesn't fill the rectangle and when I call ``` g2.fill(new Rectangle2D.Double(....)); // g2 is an instance of Graphics2D ``` then id doesn't generate border.

Original source