|
|
Buttons with rounded edges
How can i make a JButton Object to have rounded edges.
Have anyone a simple example?
|
|
0
|
|
|
|
Reply
|
theodosisx
|
6/23/2004 1:37:35 PM |
|
"Theodosis Ekizoglos" <theodosisx@yahoo.com> wrote in message
news:6b6bbb77.0406230537.e715df7@posting.google.com...
> How can i make a JButton Object to have rounded edges.
> Have anyone a simple example?
The easiest way is probably to do:
myJButton.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
myJButton.setIcon(...);
myJButton.setPressedIcon(...);
--
Mike W
|
|
0
|
|
|
|
Reply
|
VisionSet
|
6/23/2004 3:32:37 PM
|
|
On 23 Jun 2004 06:37:35 -0700, theodosisx@yahoo.com (Theodosis
Ekizoglos) wrote or quoted :
>How can i make a JButton Object to have rounded edges.
>Have anyone a simple example?
you could use a transparent icon.
see http://mindprod.com/jgloss/jbutton.html
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
|
|
0
|
|
|
|
Reply
|
Roedy
|
6/23/2004 6:28:27 PM
|
|
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
|
|
0
|
|
|
|
Reply
|
phusion
|
6/23/2004 8:06:54 PM
|
|
phusion-88@excite.com wrote in message news:<bd1b8e82.0406231206.120ec6e9@posting.google.com>...
> 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.
|
|
1
|
|
|
|
Reply
|
theodosisx
|
6/24/2004 8:17:52 AM
|
|
"Theodosis Ekizoglos" <theodosisx@yahoo.com> wrote in message
news:6b6bbb77.0406240017.7f07b503@posting.google.com...
> phusion-88@excite.com wrote in message
news:<bd1b8e82.0406231206.120ec6e9@posting.google.com>...
> > 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.
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
|
|
1
|
|
|
|
Reply
|
Adam
|
6/24/2004 9:13:50 AM
|
|
> 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.
--
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
|
|
0
|
|
|
|
Reply
|
ak
|
6/25/2004 6:58:44 AM
|
|
|
6 Replies
817 Views
(page loaded in 0.194 seconds)
|
|
|
|
|
|
|
|
|