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.
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!!
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.
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!
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
Post by:autobot
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
a bit of art, as a gift, that will fit in a stocking