Area Intersect : Area Calculation « 2D Graphics GUI « Java

Area Intersect

Area Intersect
import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import javax.swing.*;

public class AreaIntersect extends JApplet {
    Ellipse2D.Double leaf = new Ellipse2D.Double(); 
    Ellipse2D.Double stem = new Ellipse2D.Double();

    Area leaf1 = new Area(leaf); 
    Area leaf2 = new Area(leaf); 

    public void init() {

    public void paint (Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        double halfWdith = getSize().width/2;
        double halfHeight = getSize().height/2;


        leaf.setFrame(halfWdith-16, halfHeight-29, 15.0, 15.0);
        leaf1 = new Area(leaf);
        leaf.setFrame(halfWdith-14, halfHeight-47, 30.0, 30.0);
        leaf2 = new Area(leaf); 


    public static void main(String s[]) {
        JFrame f = new JFrame("Pear");
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
        JApplet applet = new AreaIntersect();
        f.getContentPane().add("Center", applet);
        f.setSize(new Dimension(150,200));;



Related examples in the same category

1.Area SubtractArea Subtract
2.Area AddArea Add
3.Area Calculation: Add, Subtract, XORArea Calculation: Add, Subtract, XOR
4.A Java implementation of the X11 region