Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

special effect for buttons and panel  RSS feed

 
shihab K Bava
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Brian Cole
Author
Ranch Hand
Posts: 935
1
  • Mark post as helpful
  • send pies
  • 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
  • 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
Ranch Hand
Posts: 935
1
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!