Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: Whats the error in my program-creating overlapping GOval objects using GraphicsProgram Date: Fri, 20 Jan 2012 21:52:39 -0500 Organization: A noiseless patient Spider Lines: 65 Message-ID: References: <532275d9-eb03-4db0-a2ef-9b051de444cc@m4g2000pbc.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 21 Jan 2012 02:44:14 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="qwFw1g9RsQ6TkML5yezG9A"; logging-data="30797"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192gH15If97Mbo/1Y9c979gnK+k3UU4ExU=" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111110 Icedove/3.0.11 In-Reply-To: <532275d9-eb03-4db0-a2ef-9b051de444cc@m4g2000pbc.googlegroups.com> Cancel-Lock: sha1:ajThEv6yELUXO8DeJViI09vvuac= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11545 On 01/20/2012 08:05 PM, student wrote: > I am trying to create three concentric circles of different color > using GraphicsProgram. However the circles never appear to be > concentric..they appear to be pushed off on the sides of each other as > if trying to show another dimension. Reread the GOval documentation. I am simply creating and adding > the GOval objects. May be I am missing something. Is there a way to > set transparency of the circles? > > Adding code below: > > import acm.graphics.*; > import acm.program.*; > import java.awt.*; > > public class Target extends GraphicsProgram { > > final static double radiusOuterCircle = 72.0; > final static double radiusMiddleCircle = 47.0; > final static double radiusInnerCircle = 22.0; > > > public void run() { > > > final double centerX = this.getWidth() / 2.0; > final double centerY = this.getHeight() / 2.0; > > > GOval g = makeCircle(centerX, centerY,radiusOuterCircle , > Color.RED); > add(g); > > > g = makeCircle(centerX, centerY,radiusMiddleCircle , > Color.WHITE); > add(g); > > > g = makeCircle(centerX, centerY,radiusInnerCircle , > Color.RED); > add(g); > > > } > > > > private GOval makeCircle(double centerX, double centerY, double > radius, Color color) > { > > GOval g = new GOval(centerX, centerY, radius, radius); > g.setFillColor(color); > g.setFilled(true); > > return g; > > } > }