• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

special effect for buttons and panel

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

I am developing an imaging application using swing. I want to give special effect for buttons on mouseentered event. For example when when the mouse moves through the button or panels it should be raised and when mouseexited it shoud be in normal position. Just like 3d effect. Could you please anybody send me some sample code or link?

Thanks and Regards
Shihab
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What have you got so far?
The "raised/lowered" effect is also possible by switching the borders on mouse entered/exited
 
shihab K Bava
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:What have you got so far?
The "raised/lowered" effect is also possible by switching the borders on mouse entered/exited



Thanks for your reply.

I have tried the following methods

1) btn.setBorder(BorderFactory.createBevelBorder(
BevelBorder.RAISED, Color.CYAN,
Color.BLUE, Color.GRAY, Color.DARK_GRAY));

2) btn.setBorder(
BorderFactory.createEtchedBorder(EtchedBorder.RAISED, Color.GRAY, Color.DARK_GRAY));

But I am not satisfied with this. Is there any others?
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

shihab K Bava wrote:when when the mouse moves through the button or panels it should be raised and when mouseexited it shoud be in normal position. Just like 3d effect.



Which part are you having trouble with, detecting when the appearance should change or deciding how the appearance should change.

Swing buttons have built in support for rollover, so detecting when the appearance should change should be fairly easy--there should be no need to track MouseEvents or anything like that.

I can't help you much with how the appearance should actually change. It's something I'd generally leave up to an artist.
 
shihab K Bava
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Brian Cole wrote:

shihab K Bava wrote:when when the mouse moves through the button or panels it should be raised and when mouseexited it shoud be in normal position. Just like 3d effect.



Which part are you having trouble with, detecting when the appearance should change or deciding how the appearance should change.

Swing buttons have built in support for rollover, so detecting when the appearance should change should be fairly easy--there should be no need to track MouseEvents or anything like that.

I can't help you much with how the appearance should actually change. It's something I'd generally leave up to an artist.



Thanks for your reply.

I know it is not easy for you to help me without knowing what is in my mind. What is in my mind is like the features of Cooliris/Picassa apperance. Like the effect when we click on the picture. I am asking is there any opensource available for this type. Hope understand me.

I already test the setRolloverEnabled and setRollOverIcon methods. But with this methods we can only change the icon of the buttons.

Thanks and Regards
Shihab
 
Brian Cole
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

shihab K Bava wrote:
I already test the setRolloverEnabled and setRollOverIcon methods. But with this methods we can only change the icon of the buttons.



Ok, but there is more to rollover than those two methods. For instance, a ChangeListener registered to the ButtonModel will be notified whenever the isRollover() state changes. You still have to handle changing the appearance, but that's what I meant by not having to track MouseEvents.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic