This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Changing Button shapes( Urgent)" Watch "Changing Button shapes( Urgent)" New topic

Changing Button shapes( Urgent)

nasmi mohamed

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 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:
subject: Changing Button shapes( Urgent)
Similar Threads
Urgent !