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

Component event ordering  RSS feed

 
Suletea Dorin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hy ,

Basically i get 2 JComponents of the same type with the same MouseMotionListeners but different sizes. (one 15/15 rectangle , other 300/300 per say)

These 2 can be on top each other. But if the small one is inside the big one it doesn't get the mouse events destined for him , instead they are grabbed by the big one,

can the layering of the components be manually modified? (set component to front set to back etc)?

I did try to grab the events from the parent Pannel and to treat those 2 like home brewed JComponents but since it's a DND application that would be devastating for the design, and for
the further work on it in general. (To be more explicit i sorted the components from JPannel by their area and dispatch events from the JPannel)

Any ideas?


Cheers , and thanks for the potential help
 
Rob Camick
Ranch Hand
Posts: 2753
11
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first thing you should do is override the isOptimizedDrawingEnabled() method of the JPanel to return false. This tells the repainting subsystem that components overlap so painting issues can be resolved properly.

Next, when you drag component you may need to reset is ZOrder to zero. Components are painted from a higher ZOrder to a lower zOrder. By assigning a 0 to the component you just moved you should ensure that it paints on top of the component you just dragged it over.



Then I would assume if the ZOrder is correct that mouse events should be passed to the proper component.

If you need more help then post a SSCCE that demonstrates the problem.
 
Suletea Dorin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your help mate. Works as expected.

createdEntityList is the list of my JComponents on the JPannel (yes i know the name is strange....) :P


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!