This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Changing Button shapes( Urgent) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Changing Button shapes( Urgent)" Watch "Changing Button shapes( Urgent)" New topic
Author

Changing Button shapes( Urgent)

nasmi mohamed
Greenhorn

Joined: Nov 28, 2001
Posts: 2
Plz anybody tell me how to change the shape of a Button or JButton in Java.For instance tell me how create and add some circle buttons.This is urgent............
Vinod Venugopal
Ranch Hand

Joined: Dec 06, 2000
Posts: 148
You can use customize your button by adding a border which will change its shape such as rounded or circular..the following code creates a rounded border..you can draw a circle to get a circular button
class RoundedBorder extends AbstractBorder
{
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
{
g.setColor ( buttonColor ) ;
g.drawRoundRect ( x , y , width , height , 4, 10) ;
g.fillRoundRect ( x , y , width , height , 4, 10) ;
//g.draw3DRect ( x , y , width , height , true) ;
}
public Insets getBorderInsets ( )
{
return new Insets ( 0,0,0,0) ;
}
}


- Vinod<br />-------<br />SCJP2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Changing Button shapes( Urgent)