Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating a red color ring in canvas

 
Michael
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to create a red colour ring in the canvas.Please reply me.I want the codes.Please Take this as a request.

Thanks in advance
 
Svend Rost
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch. You ought to take a look at: The Naming Convention

Please reply me.I want the codes

Umm...
Take this as a request

Ok. Done.

Anyways, onto your request. What kind of ring to you want? An image, or
just a drawn circle? Please me more specific.

For information about the Graphics class in J2ME, take a look at: http://www.kickjava.com/3204.htm


/Svend Rost
 
Michael
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for replying me.I want a red colour ring not an image.
Its is like white coloured small circle inside an big red circle and background of the canvas is white.So it looks like a red coloured ring.
 
Jeff Jetton
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, well, it sounds like you're on the right track, conceptually. What have you got so far? Does your app create the canvas okay? Can you have it draw anything on the canvas?

Assuming that you've gotten that far, the next steps are:

1) Set the drawing color to red. Use the setColor() method of the Graphics class for this.

2) Draw your large circle whereever you want. Use fillArc() method of the Graphics class for this.

3) Set the color to white.

4) Draw your small circle. You'll probably need to experiment a bit with different x/y offset values to get it to look the way you want.

- Jeff
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Michael"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark
 
Michael
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got the following codes for big red circle.
{
g.setColor(0xFFFFFF);

g.fillRect(0,0,getWidth(),getHeight());
int diameter=getWidth()/2;
g.setColor(color);
g.fillArc(diameter/2,diameter/2,diameter,diameter,0,360);
g.setColor(0x000000);
g.drawString(getNameFromProfile(),getWidth()/2,getWidth()/2,Graphics.HCENTER|Graphics.TOP);
}

I want the parameters for g.fillArc of the new small white circle.I tried different parameters.But i didn't got it correct.Can u plz try for me.
Thanks.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael, please read my previous post and change your display name.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic