Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Changing Button shapes( Urgent)

 
nasmi mohamed
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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) ;
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic