• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How i can make a swing button to looks like arrow

 
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is it possible to make a swing button to looks like a arrow ?
In my swing application i need 4 arrows but i could not change the button to any shape
except its rectangle like shape.
I even made my images but those does not affect rectangular shape of jbutton.
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can attach an Icon to the Button. This will however just show the Icon on a Rectangular area. You may at most set the extra Area as Invisible so that the user feels that the Shape is different. The Clicks on the Invisible Area will still be generating the Action Event.
Hope that helps!!
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A possible solution would be to implement your own
LookAndFeel for a button. You would have to override
the screen painting method and provide your own
implementation that draws the shape of an arrow
instead of a box.
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is a good idea. I had once tried that but i remember that what it did was the same. I think that the area is allocated to the button and then whatever you do it will be within that limit. Same is the case with most other components as well. I may be wrong!
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another Approach, if you really want that extra area to be not clickable, you could use the MouseListener instead of the ActionListener and manualy check if the Click is on the area of the Arrow. But remember you will also have to take care to make the button pressed icon and icon as the same. Depending on whether the mouse pressed is in the valid area, you will have to set the icon appropriately.
Best of Luck
 
reply
    Bookmark Topic Watch Topic
  • New Topic