Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Elevated button on mouse over

 
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
 
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
 
What do you have in that there bucket? It wouldn't be a tiny ad by any chance ...
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic