Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Draw a Border Around an Oval

807569Jul 8 2006 — edited Jul 8 2006
All,

I have a snippet of code below that iterates over the literals of an enum type to paint coins at specific location on a JPanel (the project is a GUI for a parking meter) that I took from one of the classes of my project. The code works fine and does what I want it to, but the problem is that when I shift the y axis of the to paint the coin at the next position it is kind of difficult to see how many coins are actuallt there. I have them overlapped slightly per the GUI requirements. My question is is it possible to draw a border around each oval representing the coin as I iterate over the literals so I can make their appearance more pronounced? Any information that anybody might be able to provide would be greatly appreciated. Thanks!

Kevin

for (Coin coins: coin.values() )
{
if(coins.number > 0)
{
y = 50;
x = x + 75;
for(int i = 0; i < coins.number; i++)
{
g.setColor( coins.color );
g.fillOval(x, y, coins.size, coins.size);
y = y + 10;

if(i == (coins.number - 1))
{
g.setColor( Color.black );

// Draw denomination label on each coin.
g.drawString(coins.denomination, (x + (coins.size/3)),
(y + (coins.size/5)));

}//End inner if
}//End inner for statement
} //End outer if statement
}//End outer for statement
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 5 2006
Added on Jul 8 2006
3 comments
376 views