| Author |
How i can make a swing button to looks like arrow
|
raminaa niilian
Ranch Hand
Joined: Jul 14, 2005
Posts: 550
|
|
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
Joined: Feb 26, 2006
Posts: 194
|
|
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!!
|
-Sam Codean<br />SCJP 1.4 (98%)<br />SCJD 5.0 (87.5%)
|
 |
Randall Kippen
Greenhorn
Joined: Oct 18, 2005
Posts: 15
|
|
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
Joined: Feb 26, 2006
Posts: 194
|
|
|
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
Joined: Feb 26, 2006
Posts: 194
|
|
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
|
 |
 |
|
|
subject: How i can make a swing button to looks like arrow
|
|
|