How to combine rectangles?

238 Views Asked by At

I am working with the Java Swing library. I have two rectangles of the same width and height and the same coordinates. I want to combine them into one so I can get a cross. How can I achieve it?

1

There are 1 best solutions below

2
Andrew Thompson On

Construct a new Area(Shape) of both rectangles, then area1.add(area2) (add one to the other).

See also the 2D Graphics trail of the tutorial.