Results 1 to 1 of 1
Thread: Area Add
-
Area Add
Java Code:import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.geom.Area; import java.awt.geom.Ellipse2D; import javax.swing.JApplet; import javax.swing.JFrame; public class AreaAdd extends JApplet { Ellipse2D.Double circle = new Ellipse2D.Double(); Ellipse2D.Double oval = new Ellipse2D.Double(); Area circ = new Area(circle); Area ov = new Area(oval); 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; circle.setFrame(halfWdith-25, halfHeight, 50.0, 50.0); oval.setFrame(halfWdith-19, halfHeight-20, 40.0, 70.0); circ = new Area(circle); ov = new Area(oval); circ.add(ov); g2.fill(circ); } 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 AreaAdd(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(150,200)); f.show(); } }"The sole cause of man’s unhappiness is that he does not know how to stay quietly in his room." - Blaise Pascal
Similar Threads
-
Area Subtract
By Java Tip in forum java.awtReplies: 0Last Post: 06-22-2008, 11:07 PM -
Area Intersect
By Java Tip in forum java.awtReplies: 0Last Post: 06-22-2008, 11:07 PM -
Text Area problem
By mcal in forum New To JavaReplies: 0Last Post: 02-11-2008, 09:42 PM -
textfiled and text area to UTF-16?
By Mr tuition in forum AWT / SwingReplies: 0Last Post: 12-04-2007, 12:40 PM -
Print Area
By Riftwalker in forum Advanced JavaReplies: 0Last Post: 11-28-2007, 07:28 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks