Results 1 to 2 of 2
  1. #1
    dvreed77 is offline Member
    Join Date
    Feb 2011
    Rep Power

    Default Mouse listening across layers


    I am having some troubles implementing mouse listening across layers.

    I currently have a panel with 2 subpanels as children laying on top of one another. The first panel has an image while the second has a shape.

    This image panel is clipped by a circle, and the shape panel adds a shape of a circle to give the clip a nice border and also has some other shapes drawn around the image in the blank area created by the clip.

    I would like to add the functionality of allowing a user to draw a box on the image but if a corner is dragged past the limits of the circle the clipping circle will automatically take care of this. This means to me that I need a listener on the image layer to take care of several different types of mouse clicks, (click press, click release, etc) .

    I also want to add a listener to the shape layer that does something else on a mouse click.

    So far I can't get these to happen at the same time. If I have a listener on the shape layer which is above the image layer, the image layer doesn't hear, but if I turn off the listener on the shape layer the image layer works fine.

    Does anyone have any suggestions?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power


    I would suggest you throw together an SSCCE that demonstrates the problem. Make it as short as possible- we probably don't need all of the clipping and drawing stuff, just a couple of JPanels with a listener set up in the way you have it. That way we have some code to work from.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

Similar Threads

  1. questions about events in differents layers
    By Jon_Xel in forum AWT / Swing
    Replies: 10
    Last Post: 07-13-2010, 05:37 AM
  2. Listening for variables?
    By martypapa in forum New To Java
    Replies: 6
    Last Post: 02-09-2010, 09:14 AM
  3. MDB listening
    By nipunalk in forum Advanced Java
    Replies: 5
    Last Post: 01-20-2010, 05:10 AM
  4. Mouse Listener for mouse floating over object?
    By Krooger in forum AWT / Swing
    Replies: 1
    Last Post: 11-18-2009, 04:34 AM
  5. Listening to a Printer
    By Mosd in forum New To Java
    Replies: 0
    Last Post: 08-12-2008, 12:21 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts