Draw two intersecting rectangles and color their intersection black.
Use draw to draw the outline of box1 and box2. Create a third rectangle, box3, where the two rectangles intersect. Use fill to draw box3 as a filled rectangle.
draw
box1
box2
box3
fill
Here is a sample program output:
Complete the following file:
Use the following file:
IntersectionViewer.java
import javax.swing.*; /** Shows a frame with two rectangles */ public class IntersectionViewer { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(300, 400); frame.setTitle("IntersectionViewer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); IntersectionComponent component = new IntersectionComponent(); frame.add(component); frame.setVisible(true); } }