The Artima Developer Community
Sponsored Link

Java Answers Forum
Why Doesn't My Code Work??

1 reply on 1 page. Most recent reply: Mar 12, 2007 1:51 AM by Uygar Donduran

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Rory Hickey

Posts: 1
Nickname: rpry17a
Registered: Mar, 2007

Why Doesn't My Code Work?? Posted: Mar 10, 2007 4:42 PM
Reply to this message Reply
Advertisement
Here is my code for a class called "Bullseye Panel":

import javax.swing.JPanel;
import java.awt.*;

public class BullseyePanel extends JPanel
{
private final int MAX_WIDTH = 300, NUM_RINGS = 5, RING_WIDTH = 25;

public BullseyePanel ()
{
setBackground (Color.cyan);
setPreferredSize(new Dimension(300,300));
}
public void paintComponent (Graphics page)
{
super.paintComponent(page);

int x = 0, y = 0, diameter = MAX_WIDTH;

page.setColor(Color.white);

for(int count = 0; count < NUM_RINGS; count++)
{
if (page.getColor() == Color.black); //alternate colors
page.setColor(Color.white);
else
page.setColor(Color.black);
page.fillOval(x, y, diameter, diameter);

diameter -= (2 * RING_WIDTH);
x += RING_WIDTH;
y += RING_WIDTH;
}
page.setColor(Color.red);
page.fillOval (x, y, diameter, diameter);

}

}


When I run it, I get a "Unexpected symbol ignored" error & it highlights the "else". Can someone help me out? Thanks!


Uygar Donduran

Posts: 1
Nickname: uygar
Registered: Mar, 2007

Re: Why Doesn't My Code Work?? Posted: Mar 12, 2007 1:51 AM
Reply to this message Reply
You can try to remove the semicolon (;) on line
if (page.getColor() == Color.black);

Flat View: This topic has 1 reply on 1 page
Topic: Why Doesn't My Code Work?? Previous Topic   Next Topic Topic: Accessing values of Strings

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use