• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

JButton Round Shape

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Is it possible to change the shape of a JButton/Button to be Round?
Could you please send me sample Code.

Regards
Naveen
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
search the forum for
circular buttons

you should find what you are looking for
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you have to do is create your own button class which extends from jbutton or button.

**) After that you can simply override the paint method(create your own) and draw the actual thing you want the button to look like. Could be round or anything. You'll need to have some skill though. After some time it won't be much of a problem..

Otherwise unless you use some new package (which is not found in the api) you better stick to the **) method
 
Author
Posts: 979
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you don't have to create your own button class. You could try something like this:



It depends on what you want to do.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Naveen Kumar wrote:Hi All,

Is it possible to change the shape of a JButton/Button to be Round?
Could you please send me sample Code.

Regards
Naveen



Try this OvalButton class I wrote.
It provides methods for setting button colours, borders, border thickness, and also the shape of the button: oval, circle, capsule.

Additionally, you can use image as the background that will only show within the shape's borders - simply override getBackgroundImage() method.

You can see some examples here.
 
Marshal
Posts: 75857
361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch and thank you for the button shape class.
reply
    Bookmark Topic Watch Topic
  • New Topic