File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How i can make a swing button to looks like arrow

 
raminaa niilian
Ranch Hand
Posts: 551
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Sam Codean
Ranch Hand
Posts: 194
  • 0
  • Mark post as helpful
  • send pies
  • 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!!
 
Randall Kippen
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic