• Post Reply Bookmark Topic Watch Topic
  • New Topic

Elevated button on mouse over  RSS feed

 
Shankar Shanmugam
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
When you create a JMenu and move a mouse over it, you can see an elevated JMenu.
You can also see that in Back/Stop/Forward buttons in IE.
Thats the wasy is works for JMenu.
But, I also need to generate such an elevated JButton for my desktop application.
Regards,
Shankar
 
ravindran shanmugam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Set a default border for the desired button,
add a mouse listener to it.
use the mouse entered and mouse exited property toggle the border property of the button.
Try this code

regards
Ravindran Shanmugam
 
Shankar Shanmugam
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for your detailed reply with a neat code.
I didn't a try with border. But, I have a problem here.
When you have a list of JButton in a sequence and try to do a mouse over.
All, the botton's location wud get affected....It willlok like all the JButton's are dancing.
There are two methods setRolloverEnabled() setRolloverIcon().
setRolloverEnabled(true) should give our expected effect. But it doesn't work and API also says that it might not work for some platform (UI L&F).
I tested it with windows.
But, setRolloverIcon() of some Icon is work fine. The icon gets changed.
After all, we don't need to capture mouse events for these two methods.
Thanks in Advance.

Regards,
Shankar
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!