Source Code : Area Intersect

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

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() {
        setBackground(Color.white);
    }

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

        g2.setColor(Color.green);

        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); 
        leaf1.intersect(leaf2);   
        g2.fill(leaf1);   

    }

    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);
        applet.init();
        f.pack();
        f.setSize(new Dimension(150,200));
        f.show();
    }

}


           
       

Thank with us