• Post Reply Bookmark Topic Watch Topic
  • New Topic

MouseListener active for Disabled JLabel

 
Ravee Bhat
Ranch Hand
Posts: 72
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey
I have a JLabel with mouselistener added.THe mouselistener is active(like mouseClicked) even when the label is disabled.
Is this the way the JLable should behave?
thanks and regards
ravee.
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JLabel is behaving correctly. I think you are confusing the two different types of event handling: low-level and semantic.
low-level: Component, Container, Focus, Key, Mouse, Paint, Window
semantic: Action, Adjustment, Item, Text
Only semantic events are affected by disabling any component. That is because they are directly handled by the component itself which is aware that it is enabled or not.
Low level events can't be affected by disabling. If you stop to think about this when you disabled your label was it still visible. If it was then the paint event must have happened. Low level events will always happen and it is up to your handlers to query the component if it is enabled or not.
Manfred.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!