> i'm not sure how to do it specifically but
> some look and feels give the rounded button effect.
> just thought i'd mention it just in case that is
> what you were looking for.
> www.javootoo.com
Thank you but:
Using (runded) images to make the illusion of a rounded JButton
isn't a "clear" solution since in this case I can't put text in
the JButton. And this is not the only disadvantage.
There is L&F managers that do the job but what if I want to have
some rounded buttons and some normal buttons?
For me is the best when I create a class JRoundedButton that overrides
the apropriate method for designing a JButton but I cann't go
deeper in this direction. I need help from someone who already did
something like that.
Adam - 24 Jun 2004 10:13 GMT
> > i'm not sure how to do it specifically but
> > some look and feels give the rounded button effect.
[quoted text clipped - 15 lines]
> deeper in this direction. I need help from someone who already did
> something like that.
What you want to do is to override paintComponent(Graphics g)
in your JRoundedButton class and do all the painting yourself there.
Kind of:
class JRoundedButton extends JButton
{
public void paintComponent(Graphics g)
{
int radius = 10;
g.setColor(getBackground());
//here comes your round button
g.fillOval(0,0,getWidth(),getHeight(),radius,radius);
//and now obtain text of the button, calculate its position
//regarding aligning and paint it with foreground color
}
}
That way you would have the same look of your round buttons
regardless of used L&F. I'd say it is not the best idea.
I would suggest creating a Border implementation
that would just take care of rendering round border
around your buttons.
Whenever you'd want a round button you would
setBorder(new MyRoundBorder())
on the one that you want to be round.
So you would not have to do all the rendering yourself,
just the border. And your RoundBorder could use
settings of the current L&F.
HTH,
Adam
ak - 25 Jun 2004 07:58 GMT
> For me is the best when I create a class JRoundedButton that overrides
> the apropriate method for designing a JButton but I cann't go
> deeper in this direction. I need help from someone who already did
> something like that.
java.awt.geom.Class RoundRectangle2D could help you.
you can also use it to set the clip of Grapihcs while painting.

Signature
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader