JLayeredPane not recieving mouse Events.

When I try to add a MouseListener to a JLayeredPane, it does not pick up the mouse events at all. Or when I even try to add it to the only JPanel I added to the LayeredPane, still no mouse events. I never set the glassPane to visible, so I have no idea why the mouse events aren't going through.

Your code won't compile. For one the layered constructor is within your MouseAdapter anonymous class. You are far better off posting compilable code here.
edit: also, you are not overriding MouseAdapter methods. That would help get your code to work.
Try compiling with an @Override annotation to see what I mean:
  private MouseAdapter exitListener = new MouseAdapter()
    @Override
    public void MousePressed(MouseEvent e) // does this compile?  MousePressed != mousePressed
      System.out.print("yrs");
  }capitalization matters:
MousePressed != mousePressed
Edited by: Encephalopathic on May 9, 2009 3:02 PM

Similar Messages

  • Not receiving mouse events

    In my ActionScript code I am adding mouse event handlers for a Canvas object (actually a subclass I wrote).  When I move the mouse over a child DisplayObject that was added to the Canvas, I receive all of the appropriate event handlers.  However, when I move the mouse over an area where there are no children, the events stop getting dispatched to my code.  I am verifying this using traces.  I do receive a mouse out and mouse over events, and I also receive a single mouse move event immediately prior to receiving the mouse over/out events, but nothing further.
    Does anybody know why the mouse events would stop when the mouse is directly on top of the Canvas object and not over any children?

    In my ActionScript code I am adding mouse event handlers for a Canvas object (actually a subclass I wrote).  When I move the mouse over a child DisplayObject that was added to the Canvas, I receive all of the appropriate event handlers.  However, when I move the mouse over an area where there are no children, the events stop getting dispatched to my code.  I am verifying this using traces.  I do receive a mouse out and mouse over events, and I also receive a single mouse move event immediately prior to receiving the mouse over/out events, but nothing further.
    Does anybody know why the mouse events would stop when the mouse is directly on top of the Canvas object and not over any children?

  • JPanels are not reading Mouse Events

    I created a basic Tic Tac Toe game, with individual "TicPanel"s inside a JPanel inside a JFrame object, however, none of the mouse events are working? Is it because the JFrame is receiving and doing nothing with the MouseEvents?
        private class TicPanel extends JPanel implements MouseListener
            private int owner; //-1 = none, 0 = O, 1 = X
            private Graphics g;
            private int num;
            ActionListener listener;
             * Constructor
            public TicPanel(int num)
                this.num = num;
                g = getGraphics();
                owner = -1;
            public void setX()
                owner = 1;
                g.drawLine(0,0,getWidth(),getHeight());
            public void setO()
                owner = 0;
                g.drawOval(0,0,getWidth(),getHeight());
            public int getOwner()
                return owner;
            public void mousePressed(MouseEvent evt){}
            public void mouseReleased(MouseEvent evt){}
            public void mouseExited(MouseEvent evt){}
            public void mouseEntered(MouseEvent evt){}
            public void mouseClicked(MouseEvent evt)
                System.out.println("works");
                listener.actionPerformed(new ActionEvent(this, num, ""));
                setX();
            public void addActionListener(ActionListener listener)
                this.listener = listener;
        }   Edited by: TheWhiteLynx on Aug 10, 2009 2:16 PM

    TheWhiteLynx wrote:
    I created a basic Tic Tac Toe game, with individual "TicPanel"s inside a JPanel inside a JFrame object, however, none of the mouse events are working? Is it because the JFrame is receiving and doing nothing with the MouseEvents?I don't see anywhere that you are adding a MouseListener to anything. Usually this is done with the addMouseListener(...) method.
    Oh, and please read the Sun graphics tutorial as this is not the way to do graphics in Swing. You do not want to get the Graphics object via getGraphics method but instead do your painting in a paintComponent override method and get your Graphics object from the parameter passed to this method. The tutorials will explain all.
    Edited by: Encephalopathic on Aug 10, 2009 2:29 PM

  • RichEditableText with embedded images does not handle mouse events reliably

    I'm using Flash Builder "Burrito".  downloaded a couple of weeks ago.  Flash Player 10.1.85.3 debug version.
    I have the following MXML object:
    <s:Scroller
    width="100%" height="100%"
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    skinClass="components.skins.SxScrollerSkin"
    >
    <s:Group id="myGroup" width="100%" height="100%">
    <s:RichEditableText id="myRichText" >
    </s:RichEditableText>
    <!--- Do not set the height of the RichEditableText - since it seems to prevent the appearance of the vertical scroll bars -->
    </s:Group>
    </s:Scroller>
    With the following Actionscript to initialize, etc.
                textContainer = new SxBorderContainer(name);
                textContainer.dx = dxAvailable;
                textContainer.dy = dyAvailable;
    scroller = new SxScroller();
    scroller.move(dxPadding,dyPadding);
    scroller.dx = dxAvailable
    scroller.dy = dyAvailable;
    textContainer.addElement(scroller);
    var richText:RichEditableText;
    richText = scroller.richText;
    richText.toolTip = toolTip;
    richText.enabled = true; // required for mouse click capture
    richText.selectable = true; // required for mouse click capture
    richText.width = dxAvailable
         var textFlow:TextFlow = TextFlowUtil.importFromString(textFlowString, WhiteSpaceCollapse.PRESERVE);
          richText.textFlow = textFlow;
    And the following code to catch events:
                    richText.addEventListener(FlowElementMouseEvent.MOUSE_DOWN,userMouseEvent);
                    richText.addEventListener(FlowElementMouseEvent.MOUSE_UP,userMouseEvent);
                    richText.addEventListener(FlowElementMouseEvent.CLICK,userMouseEvent);
    Here's the problem.   If I have embedded images in the TextFlow that is imported into the richText, I only catch "some" mouse clicks.  It's hard to know, but it seems that only mouse clicks into white space (between paragraphs) are caught.  Mouse up and down are caught, but not "click".  Very puzzling.
    TextFlow like this:
        <TextFlow>
          <div color="#442222" fontFamily="Times New Roman" fontSize="20" paragraphSpaceAfter="15" textIndent="15">
            <p>
              <span>
                Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do:  once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, `and what is the use of a book,' thought Alice `without pictures or conversation?'
              </span>
            </p>
            <p>
                  <span>So she was considering in her own mind</span>
                  <img source="assets/library/alice/images/White Rabbit.png" height="auto" width="auto" float="left" />
                   <span> (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.</span>
            </p>
    If there are no embedded imags, I get all clicks exactly.
    Is it a bug?  Am I missing something? 
    Thanks,
    Oz

    Thanks for the answer. First I need clicks anywhere in the RichEditableText (no links or images). I use the selection manager to find the exact word that was clicked.
    The next step would be to capture clicks on links and images.
    I have tried using MouseEvent and had the same result (or worse) as FlowElementMouseEvent.  I will go back and retest with your suggestion.
    Oz
    Result of retest:
    I catch clicks only over images embedded in the TextFlow.  I catch only mouse up/down over text - both MouseEvent and FlowElementMouseEvent.
    Puzzling.  Where are the clicks going?

  • Problem with TextLine not getting mouse events when expected

    Hi All,
    I am cross-posting the discussion I put on the TLF forum here (sample code is in that post)
    http://forums.adobe.com/message/3768763#3768763
    The issue is to do with non/slow response when clicking to edit multiple TLF text elements on a base group. Thanks to some extra work by Jin-Huang the problem is apparently that when the edit functionality is set (by setting the interactionManager), the TLF class cannot receive any more events until the mouse leaves and re-enters the TextLine you are supposed to be editing. This sounds like a Flex bug.
    I guess my questions are (1) is this actually a Flex bug? and (2) does anyone know a workaround so the thing can start accepting input immediately without further mouse actions?
    Thanks,
    Darryl.

    What happens if you use two RichEditableText controls or two TextAreas
    instead?  By trying to install your own editing controls, you might have to
    fully conform to the IFocusManagerComponent interface for focusable
    components otherwise you might run into issues like this.

  • JPanel cannot recieve Key Events?

    Hi. I'm trying to make a simple game, which recieves input from the arrow keys and spacebar. The drawing is done inside a paintComponent() method in a JPanel. Therefore, the key events should also be handled in the same JPanel. I can call the addKeyListener() method on the JPanel, but it does not recieve key events. I've tried calling setFocusable(true) but it doesn't seem to do anything. If JPanel can't recieve key events (it can recieve mouse events fine), I have to handle the events in the JFrame, which I'm hesitant to do. My book does it in an applet and applets can recieve key events fine, but I want to make an application.
    No working source code here, try to figure out what I'm saying.
    Thanks.

    Please help me. I did help you. I gave you a link to the tutorial that shows that proper way to do this.
    All Swing components use Key Bindings so you might as well take the time to understand how they work.
    Anyway, based on your vague description of the problem we can't help you because we don't know the details of your code.

  • Cut or Inverse Masking via Blend.Layer + Blend.Erase = no mouse event listener for objects behind "glass wall"

    I've successfully erased unwanted graphics using Blend and I can drag a desired object that is behind the erased area, but the dragged object does not have mouse events unless I drag if from behind the erased area.  Does anyone know a good work around or how I can force the event to be dispatched when the object behind the "glass wall" is clicked?  I can't find documentation anywhere that addresses this situation.  If an object behind can not be selected how is it really erased?  Thanks in advance!

    Yes, and I want to keep it behind.  It's visible and can be dragged, but
    since behind the transparent area that has been erased using Blend.Erase it
    no longer receives click events.  Thanks for your response.
    Michelle

  • Transparent parts of component are preventing mouse events

    Hello,
    I am working with a bunch of components that are layered over top of eachother.
    Some of the components are odd shaped and have a transparent background.
    When I try to click on components that are behind others the mouse event is not fireing.
    is ther a way I can fix this?
    Drew

    There is a difference between transparent background and no background.  If I take a Sprite and draw a filled triangle like this:
    moveTo(0,0)
    lineTo(100, 100)
    lineTo(100, 0)
    lineTo(0,0)
    Then any component under the half I didn't draw on is "visible" to the mouse and my Sprite will not get mouse events.
    If I fill that area with a background with alpha=0, then I've effectively placed a piece of glass in my component and it will get mouse events even though you can see through to things behind it.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Mouse events fires on invisible plot drawn in cwgraph

    i have drawn a plot(which is invisible) on a cwgraph and set graph trackmode to cwgtrackallevents.Mouse events(plotmousedown/plotmouseup) are still fired for this invisible plot.

    Hey Vishal,
    What version of the cwgraph are you using? I tried the following program with CWGraph version 7.1 and I did not receive mouse events for the invisible plot.
    CWGraph1.PlotY (y)
    CWGraph1.Plots(1).Visible = False
    CWGraph1.TrackMode = cwGTrackAllEvents
    I also tried the PlotMouseMove event and I received this event if the plot was visible and didn't if it was invisible. This event was a lot easier to test. It's hard to click on an invisible plot. Did you see the same behavior with PlotMouseMove?
    There are some known issues with invisible plots in earlier versions of Measurement Studio. Please see link below. If you are using an old version then I would assume this is the problem.
    RHIVEID=101&RNAME=ViewQuestion&HOID=5065000000080000007A2B0000&ECategory=Measurement+Studio.For+Visu...
    I hope this helps!
    Regards,
    Sarah Miracle
    National Instruments

  • Mouse events triggered on touch

    In a multi-touch application, looks like the mouse events are triggered also on touch, so there is no way to detect if it was a cursor mouse down or a touch screen touch begin. Is this the case?
    Thanks, chr

    Hey Vishal,
    What version of the cwgraph are you using? I tried the following program with CWGraph version 7.1 and I did not receive mouse events for the invisible plot.
    CWGraph1.PlotY (y)
    CWGraph1.Plots(1).Visible = False
    CWGraph1.TrackMode = cwGTrackAllEvents
    I also tried the PlotMouseMove event and I received this event if the plot was visible and didn't if it was invisible. This event was a lot easier to test. It's hard to click on an invisible plot. Did you see the same behavior with PlotMouseMove?
    There are some known issues with invisible plots in earlier versions of Measurement Studio. Please see link below. If you are using an old version then I would assume this is the problem.
    RHIVEID=101&RNAME=ViewQuestion&HOID=5065000000080000007A2B0000&ECategory=Measurement+Studio.For+Visu...
    I hope this helps!
    Regards,
    Sarah Miracle
    National Instruments

  • Mouse event not fires on drag and drop

    Please
    Can any one help and give any idea during draging(drag drop) mouse over of a button does not fires. I have a list of thumb in which I want to drag and drop the thumb at any location for reordering the thumb but due to  lot of item in list need to sscroll list.  I have my own custom scroll on button mouse over but when Item is dragging  mouse event does not fires.
    Thanks in advance,
    Premkant

    Hi there,
    Reject caption shows up when an unacceptable source is dropped on a Target. To configure the 'Accept criteria', select a drop target, Click on the 'Accept' button, Deselect the checkbox corresponding to the unacceptable source. (As shown below)
    Now whenever the user drops 'Unaccept' source on top of the target, the 'Reject' caption shows up.
    Thanks,
    Nimmy Sukumaran.

  • Mouse event not working on JTable in JAVA 1.4.2

    mouse event is not recognised on empty table when using with java 1.4.2. Please specify if there is any chnge done for mouse event capture for table from java 1.3.1 to java 1.4.2.
    since mouse events are working fine for JTableHeader.
    if anybody have an idea please let me know.

    Hi
    JTable is there on JPanel . same code is working in JAVA 1.3.1
    actually its a bug in java 1.4.2 ( ref. bug_id=4940522 )
    here is the code reference..
    public class TableEditor extends JPanel
    �implements ListSelectionListener, Selector, Editor
    private JTable�myTable;
    private JPopupMenu myPopup;
    private Vector�myActions;
    private Vector�myListeners;

    public TableEditor(String anAssociation, Editor anEditor, int type)
    super(new GridLayout(1,1));

    myListeners = new Vector();
    myActions�= new Vector();
    myPopup�= new JPopupMenu();
    myTable�= new JTable();
    ��
    myTable.getSelectionModel().addListSelectionListener(this);
    myTable.addMouseListener(new MouseAdapter() {
    �public void mouseClicked(MouseEvent me)
    �{
    � if ((me.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
    � {
    ��// Update actions in case ListSelectionModel are out of sync.
    ��for (int i = 0; i < myActions.size(); i++)
    ��{
    Object o = myActions.elementAt(i);
    if (o instanceof SelectorAction)
    ((SelectorAction)o).check();
    ���}
    myPopup.show(myTable, me.getX(), me.getY());
    �}
    // Added mouse listener to JTableHeader
    // This is a temporary solution to open popup menu on blank table,
    // as in Java 1.4.2 no mouse event captured on blank table.
    // So for now we will capture the event from the table header.
    JTableHeader myTableHeader = myTable.getTableHeader();
    myTableHeader.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent me)
    �{
    if ((me.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
    // Update actions in case ListSelectionModel are out of sync.
    for (int i = 0; i < myActions.size(); i++)
    ��{
    Object o = myActions.elementAt(i);
    if (o instanceof SelectorAction)
    ((SelectorAction)o).check();
    ���}
    myPopup.show(me.getComponent(), me.getX(), me.getY());
    � }
    �});
    The solution given is temporary ( adding JTableHeader component)..
    we want to retain the same functionality .. mouse event should get captured on empty table only..

  • My wife recieved invite event from my PC Outlook. She accepted it, but it never showed up on her iCloud or iCal on our iMac. Then I removed her as an invitee and it did not remove the event from her iPhone. So now she has a event on her iPhone that can't

    My wife recieved invite event from my PC Outlook. She accepted it, but it never showed up on her iCloud or iCal on our iMac. Then I removed her as an invitee and it did not remove the event from her iPhone. So now she has a event on her iPhone that is not on either her iCloud or iCal. How do I remove it from her iPhone?

    1) You asked "Does she need to reconnect to that itunes/computer and if so what do we need to do to remove this folder of pics from her ipod?" Yes, you have to connect the iPod to that computer and go to the Photos pane for the iPod in iTunes and uncheck sync photos and the click on synce/apply. In the future do not check sync photos.
    iOS and iPod: Syncing photos using iTunes
    2)
    Create a NEW account for using these instructions. Make sure you follow the instructions. Many do not and if you do not you will not get the None option. You must use an email address that you have not used with Apple before.
    Creating an iTunes Store, App Store, iBookstore, and Mac App Store account without a credit card
    Then on the iPod go to
    - Settings>Messages>Send and receive and sign out your ID and sign into hers. Make sure that only her ID email address is listed.
    - Settings>FaceTime sign out of your ID and sign into hers. Make sure that under You can be reached at only her ID email address is listed
    - Settings>iCloud and sign out and sign in with hers
    Contnue to use the commpn ID/account for Settings>iTunes and App stores.

  • Firefox mouse event not behaving the same on PC and Mac computers

    I use the FCKEditor and having a very strange problem. When I click on the FCKEditor's editing area, the keyboard gets disabled untill I click the mouse somewhere outside of the editing window. The problem only happen on Firefox (3.6.10) on Mac computer (Snowleopard 10.6.4). Doing exactly the same steps on PC works without any problem.
    What I want to know:
    - Is it possible that the Firefox on Mac is different than the PC in handling mouse events? Or some other areas?

    Sounds more that Firefox is treating that editor area as read-only.
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]

  • Recieving Mouse/Keyboard events in independent object?

    I'm currently writing a class Map, which is supposed to, surprise, display and handle a map. There is no separate window or similar for it, and thus, I figured that the class using an instance of Map would have to send any events separately to 'their' methods in the object. my question is, is this really necessary, or is there a possibility to register such events directly to the Map class?
    what I now have is something like this:
    public class Parent extends Applet implements KeyListener {
      Map m = new Map();
      public void init() {
        addKeyListener(this);
    //etc.
      public void keyPressed(KeyEvent e) {
        m.keyPressed(e);
    } //end of Applet
    class Map {
      public Map(){}
      public void keyPressed(KeyEvent e) {
        System.out.println("Recieved key event from Parent: "+e);
    }any wise suggestions?
    thanks in advance
    beaVer

    hell, it doesn't work yet. does anybody know what i'm doing wrong?
    public class TrivialApplet extends Applet implements KeyListener {
      Map m = new Map();
      public void init() {
        addKeyListener(m);
    //etc
    class Map implements KeyListener {
      public void keyPressed(KeyEvent e) {
        System.out.println(""+e.getKeyCode());
    }it simply doesn't work :/

Maybe you are looking for

  • Notification sounds/vibrate not working iOS 5

    Updated to ios 5....I have several notifications other then just email and SMS...CNN, breaking news...the like. The apps themselves have sound preferences...and I have their sounds set in notification as well. Yet the pop up shies up at top...no soun

  • Cannot transfer Library from Mac Power G4 to new Macbook Pro via MA

    I just bought a MacBook Pro for my daughter, and tried to copy the files from old PowerBook G4. Applications and files are fine but not the library which is grayed out. I do not know whether the username causing the problem, as the account name of th

  • Lion back browser

    I currently use 3 fingers to swipe back and forth in my internet browserinstead of using the buttons. In lion, it says 3 fingers swiped left or right switches applications. If I upgrade to Lion, will I lose the ability to swipeback in web browser pag

  • Smart forms - Dynamic sizing of the windows.

    Hi gurus, iam working on smartforms, i have a problem. My requirement is: Printing a table data on the smart form. Is the window which prints this table data is resized with the amount of table data, if so, what is the procedure i should follow for t

  • Livecycle form

    hi, i have a livecycle expandable form. here there is a table and add row and remove row button for adding and removing table row.when i add additional feature for save form with data it will automatically show 10 rows of table as default. i want onl