Forums Register Login

How i can make a swing button to looks like arrow

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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!!
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
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
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
https://gardener-gift.com


reply
reply
This thread has been viewed 1343 times.
Similar Threads
Do multiple-step enabled Undo/Redo JButton on toolsbar?
How to start?
online help document problem
AWT Combo Box
Xcode 4 configuration
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:03:12.