Help dispatching events from glassPane to other components

Hi guys,
I laready did a search in the forum but everybody seems to have trouble blocking events via GlassPane.
For me it is the opposite.
I set a glassPane on the Frame via setGlassPane()... works great but now i can't dispatch the events to the rest of the UI. Can someone please give me some example code how to do that;
Here is what i have tried :
myFrame.this.getGlassPane().addMouseListener(new MouseAdapter()
public void mouseClicked(MouseEvent e)
Frame.this.getRootPane().dispatchEvent(e);
public void mousePressed(MouseEvent e)
Frame.this.getRootPane().dispatchEvent(e);
public void mouseReleased(MouseEvent e)
Frame.this.getRootPane().dispatchEvent(e);
public void mouseEntered(MouseEvent e)
Frame.this.getRootPane().dispatchEvent(e);
public void mouseExited(MouseEvent e)
Frame.this.getRootPane().dispatchEvent(e);
Please show how it is done ...

Hey Tom,
You know what's funny, i read that article already and even look at the code but it was too complicated for me...And now that you mentionned it again i decided to look at it again and took one method out of it and now it seems to work but i still don't quiet understand what it does exactly??? Thanks For pushing My Back :)
Any Other way to do that ???
private void redispatchMouseEvent(MouseEvent e)
Point glassPanePoint = e.getPoint();
Container container = this.getContentPane();
Point containerPoint = SwingUtilities.convertPoint(this.getGlassPane(), glassPanePoint,container);
//The mouse event is probably over the content pane.
//Find out exactly which component it's over.
Component component =
SwingUtilities.getDeepestComponentAt(
container,
containerPoint.x,
containerPoint.y);
if ((component != null) )
//Forward events over the check box.
Point componentPoint = SwingUtilities.convertPoint(
this.getGlassPane(),
glassPanePoint,
component);
component.dispatchEvent(new MouseEvent(component,
e.getID(),
e.getWhen(),
e.getModifiers(),
componentPoint.x,
componentPoint.y,
e.getClickCount(),
e.isPopupTrigger()));

Similar Messages

  • Dispatching event from Javascript

    Can I dispatch events from javascript to flash player? I am trying to do so by calling dispatchEvent() on flash player dom object but the event is not passing inside flash player. Any links or clue?

    To be specific ... I can catch a right click and supress it. But I want to send it to flash (lets say) as a left click. Problem is when i do that, javascript listner for dom element will get fired for left click but there wont be any events in flash.
    SO the question is can i fire events on flash from outseide or is it outside the public APIs?

  • Dispatch event from itemrenderer

    Greetings.
    i've got a main applicationxml: main.mxml
    followed by a component: optionbox.mxml, being loaded in the
    main.mxml.
    in optionbox.mxml another component is loaded:
    optionCanvas.mxml
    inhere, a datagrid is being created with a custom
    itemrenderer: itemsRenderer.mxml
    in this itemsRenderer (wich alters the display of the cells)
    is an image located.
    when you click this image, an object has to be dispatched to
    the main.mxml.
    how can I do this? It works when I dispatch from a component,
    but not from an itemrenderer.
    can anyone help me out.??
    main.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical"
    xmlns:c="comp.*"
    backgroundAlpha="0"
    backgroundColor="#FFFFFF">
    <mx:«»Style>
    global{
    fontFamily:Arial;
    Canvas{
    color:#000000;
    .FooterLink{
    color:#0066CB;
    fontWeight:Bold;
    fontThickness:900;
    .Footer{
    backgroundColor:#E1F0F7;
    DataGrid{
    borderThickness:0;
    selectionColor:#FFFFFF;
    selectionDisabledColor:#FFFFFF;
    disabledColor:#FFFFFF;
    rollOverColor:#FFFFFF;
    ToolTip {
    fontFamily: Arial;
    fontSize: 12;
    color: #000000;
    </mx:«»Style>
    <mx:«»Script>
    <![CDATA[
    import events.itemEvent;
    import mx.rpc.events.ResultEvent;
    import mx.collections.ArrayCollection;
    [Bindable]
    private var selectedItems:ArrayCollection = new
    ArrayCollection();
    private function photoSelectedHandler(event:itemEvent):void{
    selectedItems.addItem(event.selectedItem);
    ]]>
    </mx:«»Script>
    <mx:VBox width="980" height="100%">
    <mx:HBox>
    <mx:VBox>
    <c:LeftPane id="leftpane" width="201" height="100%" />
    <c:Checkout id="checkout" selectedItems="{selectedItems}"
    styleName="checkout" fontWeight="bold"/>
    </mx:VBox>
    <c:«»Swfcontainer width="537"
    height="405" />
    <c:OptionBox width="222" height="100%" id="optionBox"
    itemSelected="{photoSelectedHandler(event)}"/>
    </mx:HBox>
    <c:Footer width="100%"
    styleName="Footer"></c:Footer>
    </mx:VBox>
    </mx:Application>
    [/code:1]
    optionbox.mxml
    [code:1]<?xml version="1.0" encoding="utf-8"?>
    <mx:HBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    color="#400000" creationComplete="printerData.send()"
    xmlns:c="comp.*">
    <mx:Metadata>
    [Event(name="itemSelected",
    type="events.itemEvent"«»)]
    </mx:Metadata>
    <mx:«»Script>
    <![CDATA[
    import mx.rpc.events.ResultEvent;
    import mx.collections.ArrayCollection;
    [Bindable]
    public var printer:ArrayCollection
    private function printerDataHandler(event:ResultEvent):void{
    printer = new ArrayCollection();
    printer=event.result.printer.confItem;
    ]]>
    </mx:«»Script>
    <mx:HTTPService id="printerData" url="data/data.xml"
    result="printerDataHandler(event)"/>
    <mx:Accordion id="accOptions" width="100%" height="100%"
    headerHeight="32" backgroundAlpha="0" fontSize="11" color="#0066CB"
    resizeToContent="true">
    <mx:Canvas label="{printer.getItemAt(0).label}"
    width="100%" height="100%" backgroundAlpha="0">
    <mx:VBox>
    <mx:Text width="198"
    htmlText="{printer.getItemAt(0).text}" />
    </mx:VBox>
    </mx:Canvas>
    <mx:Repeater id="repAccOptions" dataProvider="{printer}"
    startingIndex="1" >
    <c:optionCanvas
    itemData="{repAccOptions.currentItem}"/>
    </mx:Repeater>
    </mx:Accordion>
    </mx:HBox>[/code:1]
    optionCanvas.mxml
    [code:1]<?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="
    http://www.adobe.com/2006/mxml"
    label="{itemData.label}" width="100%" height="100%"
    verticalScrollPolicy="off">
    <mx:«»Script>
    <![CDATA[
    [Bindable]
    public var itemData:Object;
    ]]>
    </mx:«»Script>
    <mx:VBox width="100%">
    <mx:Text width="100%" htmlText="{itemData.text}" />
    <mx:«»DataGrid
    dataProvider="{itemData.consumables.consumable}"
    headerHeight="0"
    width="100%" itemRenderer="itemRenderers.OptionsRender"
    alternatingItemColors="#FFFFFF">
    <mx:columns>
    <mx:«»DataGridColumn
    dataField="consumableLabel" width="200"/>
    </mx:columns>
    </mx:«»DataGrid>
    </mx:VBox>
    </mx:Canvas>[/code:1]
    optionsRenderer.mxml
    [code:1]<?xml version="1.0" encoding="utf-8"?>
    <mx:HBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    verticalScrollPolicy="off" horizontalScrollPolicy="off" width="165"
    height="45">
    <mx:Metadata>
    [Event(name="itemSelected",
    type="events.itemEvent"«»)]
    </mx:Metadata>
    <mx:«»Script>
    <![CDATA[
    import events.itemEvent;
    [Bindable]
    public var selectedItem:Object;
    private function addItem(itemObj:Object):void{
    selectedItem = new Object();
    selectedItem = itemObj;
    var eventObj:itemEvent = new
    itemEvent(selectedItem,"itemSelected"«»);
    dispatchEvent(eventObj);
    ]]>
    </mx:«»Script>
    <mx:Image source="assets/btnAddItem.jpg"
    click="addItem(data)"/>
    <mx:Text htmlText="{data.consumableLabel}"
    height="45"/>
    <mx:Image source="assets/btnInfoItem.jpg"
    horizontalAlign="right">
    <mx:toolTip>
    {data.consumableLabel}
    Partnumber:{data.consumablePartnr}
    Price:{data.consumablePrice}
    Omschrijving
    {data.consumableDescr}</mx:toolTip>
    </mx:Image>
    </mx:HBox>[/code:1]

    Override clone() method inside event to make sure you take into account the bubbling property, and then inside renderer dispatch the event with bubbling property set to true.
    Alternatively you can dispatch on the list e.g :
    owner.dispatchEvent(newCopyProductEvent(CopyProductEvent.COPY_PRODUCT,o));
    If you choose to do the latter make sure you don;t get into an infinite loop inside list if you decide to redispatch from there,
    C

  • Events from main application to components

    Could someone please tell me if it's possible to broadcast an
    event from the main application to components that have been
    declared inside the main application?

    For the number of rows in the DataGrid just look at the length of the dataProvider.
    For passing data between popups and app, the gold standard is to use custom events, and add the event listener to systemManager.
    Here are some tutorials on custom events I created:
    http://chikaradev.com/learning/flex3/customevents/StudentsTutoringCustomEvents1.pdf
    http://chikaradev.com/learning/flex3/customevents/CustomEventSimple/CustomEventSimple.html
    http://chikaradev.com/learning/flex3/customevents/CustomEvents1/index.html
    If this post answers your question or helps, please mark it as such.
    Greg Lafrance - Flex 2 and 3 ACE certified
    www.ChikaraDev.com
    Flex Training and Support Services

  • Dispatch event from the main App file

    Hi,I have one simple question.I know how to dipatch events from the some of the components files to the main App file,but I don't know how to do the opposite?
    I have an HTTPService with id = "getData" in some component file and I want to dispatch an event that will send it getData.send();
    Is this possible,and it if is how?

    It is possible but not a recommended practice.
    Worst case you proxy out methods on your components and call directly:
    maiAPpp.someComponent.doSomething();
    SomeComponent
    doSomething();
        someOtherComponent.doSomething();
    SomeOtherComponent
    doSomething();
        servcie.send();
    My 2 cents are too look into MVC architecture and have the service inside a command which gets treiggered by a controlled which reacts to your event dispatched by the view.
    C

  • Dispatching event from skin

    Can I dispatch an event from the skin and have the hostcomponent listen it?  I have a text input and an info icon in frnt of it,  I want to show the tooltip of the textinput when there is a rollover event on the icon. I wrote a skin with the textinput and icon and in the rollover event on the icon I am dispatching an event and added an event listener to the hostcomponent of the skin. It seems like hostcomponent is not listening the event.
    My skin handles all the animation logic and contains the image and the textinput,and then I am extending the skinnable component class with the two skin parts and controlling the skin states from there. In the rollover event I dispatched an event which host omponent is supposed to catch and do the following:
    myTextInput. tooltip = _toolTip
    _toolTip is in the construcotr of the hostcomponent.
    What is wrong in what I did?  Why is my host component not receiving a event from the skin?

    Thanks for your reply. My code is kinda long and apparently I can't copy paste in this window(not sure why).
    Is there any way to attach the code somehow?

  • Dispatching events from JNI

    I've got an application that is trying to watch for mouse events anywhere and everywhere. The goal is to be in-the-know when there is mouse activity going on in general, with the Java app running in the taskbar.
    I have determined that I'll likely need JNI to accomplish this, as paying attention to mouse activity over the whole operating system is somewhat operating system dependent. : )
    Nevertheless, I'd like Java code to handle the events, and I can't seem to find any way for JNI to dispatch events back to the Java side of things. My hope was to catch the events thrown by the system in C/C++ and then simply dispatch them again to act as a middle-man.
    If anybody can tell me how I might accomplish this using JNI, or even a step in the right direction, I would greatly appreciate it. Or, if I'm barking up the wrong tree, please please let me know.
    Thanks,
    - J

    Steps in order
    1. Determine how to capture the events in C/C++. There is no java in this step.
    2. Write an API in C/C++ that models the functionality that you want to use in java. There is no java in this step.
    3. Write java/jni that uses the API in 2. There is java in this step.
    As a callback you will need to use the jni attach thread method.
    You better be careful as messing up on any of the steps above can render your mouse inoperable for the entire OS, so learn the keyboard shortcuts.
    I think that someone posted code like this in the past. I could be mistaken however.

  • Can you dispatch events from a custom component skin?

    If so, how?
    Thanks~Benny

    I'm curious to know if this is possible as well (or really the question should be, is there a non-hackish way to get a reference to the skin instance)?
    When I've needed to do something like this, I've always just dispatched an event off a skin part from within my skin. IE.
    this.contentGroup.dispatchEvent(...)
    Then I would just listen for the event on the skin part.
    This is a bit hackish, so it would be nice if someone could share a better solution. I've been meaning to look into it, just never have been able to justify the time looking for a better solution.

  • How to dispatch events from custom AS3 classes to MXML

    Hello,
    I introduce some custom classes inside my SCRIPT tag in MXML.
    These classes should dispatch custom Events (or any events for that
    matter) and the listeners should be defined inside the SCRIPT tag.
    In the custom class I have:
    quote:
    dispatchEvent(new Event("customEvent"));
    And inside the script tag:
    quote:
    addEventListener("customEvent", testListener);
    quote:
    public function testListener(evt:Event):void{
    Alert("Event fired successfully.");
    However, this event is not handled in the listener (the alert
    is not shown). What could be wrong?

    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" creationComplete="init();">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    private function init():void
    addEventListener("customEvent", testListener);
    dispatchEvent(new Event("customEvent"));
    private function testListener(evt:Event):void{
    Alert.show("Event fired successfully.");
    Do like this
    Alert is the Class Object. This is not the Function.

  • JMenuBar, losing focus from JTextPane or other components

    Hello,
    I implment JMenuItems for copying, cuting and pasting text from one JTextPane into another JTextPane.
    The problem is that when I click on the JMenuBar-->JMenuItem, the focus from JTextPane is lost. It works fine if I use JButton on a JToolBar.
    The code below is my paste() method that does not work.
    public void paste() {
            if (sourceWindowTextPane.isFocusOwner()) {
                sourceWindowTextPane.paste();
            } else if (targetWindowTextPane.isFocusOwner()) {
                targetWindowTextPane.paste();
        }What do I need to do?

    Thank you very much, uncle_alice.
    I found a weird solution. I get the name of the current focus owner first, and then I compare the returned name with
    names of my JTextPanes. The working code is shown below.
       String focusOwnerName=this.getContext().getFocusOwner().getName();
            if (focusOwnerName.equalsIgnoreCase("sourceWindowTextPane")) {
                sourceWindowTextPane.paste();
            } else if (focusOwnerName.equalsIgnoreCase("targetWindowTextPane")) {
                targetWindowTextPane.paste();
            }However,
    although I know the the focus owner's name is "sourceWindowTextPane" from this.getContext().getFocusOwner().getName(),
    I still get false when I use sourceWindowTextPane.isFocusOwner(). For example,
       String focusOwnerName=this.getContext().getFocusOwner().getName();//-->for instance, focusOwnerName is "sourceWindowTextPane".
       if(sourceWindowTextPane.isFocusOwner()){
             System.out.println("True");
      } else{
              System.out.println("False");
    I get "False" from the code above.
    Does anyone have any idea?

  • Dispatchig event from one module and listen it in an other module

    Hi,
    I would like to know if it's possible to dispatch event from module for example "M1" and listen this event to call the corresponding command but in an other module "M2". Knowing that M1 produces an swf "SWF1" and M2 produces an other swf "SWF2". For example :
    In the view of a module M1, I should have this statement : CairngormEventDispatcher.getInstance().dispatchEvent(new MyClassEvent(parm));
    know in module "M2" I would like to know how to recover this event and then executing command corresponding to this event.
    If it's not clear enough I can explain it again.
    I need really your help for the rest of my development.
    Thank you in advance. :)
    Ziad.

    Hi Ziad,
    Sorry, but this forum is for discussing the future of cairngorm, not how to use it today.
    I suggest you post your question on the FlexCoders mailing list or on the Cairngorm Documentation Group :
    http://tech.groups.yahoo.com/group/cairngorm-documentation/
    Thanks ;)

  • Dispatch custom event from itemClick handler

    hi,
    I'm trying to dispatch a custom event from my itemClick handler.
    So when I click on an item of my datagrid, I want to send a custom event.
    private function dataGridItemClickHandler( event:ListEvent): void
         dispatchEvent( new myEvent( myEvent.NEW, values[event.columnIndex]["name"]) );
    <mx:DataGrid dataProvider="{values}" itemClick="dataGridItemClickHandler(event)">
    </mx:DataGrid>
    but this code doesn't work.
    Can you help me
    thanks
    best regards

    Please see that you override the function clone() and return the new function.If that is correct.you can call the super() method to initialize your base class.
    If your custom event {myEvent} is in package say: CustomEvent,
    1)import package CustomEvent.myEvent
    2) keep in <mx:metadata>[Event(name="NEW", type="CustomEvent.myEvent")]</mx:metadata>.. name suggest  what type of event you want
    3)Create an itemclick listener and in dataGridItemClickHandler
    private function dataGridItemClickHandler( event:ListEvent): void
         dispatchEvent( new myEvent( ' NEW ', values[event.columnIndex]["name"]) );
    private funcation myEventListener(evt:myEvent):void
    //Put your logic
    4)Use this event by name NEW="myEventListener(event)"  this will behave as event type in the datagrid tag like click, hover and others.
    Hope this helps! Please excuse if anything is logically incorrect.Do point out.Thanks.

  • If OSMFSettings.enableStageVideo true, then click event from the MediaContainer is not dispatch.

    Hi!
    I use org.osmf.vast.mediaVAST2TrackingProxyElement from the VASTLibrary for display advertising and use click to handle advertisement redirection.
    It's works for flash.media.Video.
    But after setting OSMFSettings.enableStageVideo = true, the click event from the MediaContainer is not dispatch.
    Can you please help?

    Actually, I looked briefly at the dev guide this week end, and Stage Video actually renders from the GPU under the Actionscript App.
    It could be something like this:
    Stage video is behind the Actionscript objects and one of them is as big or bigger than the video rendering rectangle and it is grabbing mouse interaction.
    Just speculating.
    Also, I'm not certain StageVideo can recieve mouse events...
    Hope this helps.

  • I need help with event structure. I am trying to feed the index of the array, the index can vary from 0 to 7. Based on the logic ouput of a comparison, the index buffer should increment ?

    I need help with event structure.
    I am trying to feed the index of the array, the index number can vary from 0 to 7.
    Based on the logic ouput of a comparison, the index buffer should increment
    or decrement every time the output of comparsion changes(event change). I guess I need to use event structure?
    (My event code doesn't execute when there is an  event at its input /comparator changes its boolean state.
    Anyone coded on similar lines? Any ideas appreciated.
    Thanks in advance!

    You don't need an Event Structure, a simple State Machine would be more appropriate.
    There are many examples of State Machines within this forum.
    RayR

  • Coalescing events from multiple components in a JPanel

    Hi,
    I've got a JPanel based form with several components (mostly JTextField) and I'd like to be able to have component events bubble up to the parent JPanel. By comparison to MFC, if I have a dialog box with several controls all of the control events will continue to percolate upwards until they are handled. Is there any such possibility with Swing?
    Ideally I would like it if all component events were routed to a single listener in the parent JPanel, all I really need to do (initially) is set a boolean to note that a change may have been made. Do I have to explicitly set a handler for each component or is there way to automagically have the parent to catch the events from its child components?
    Thanks!
    jam

    Thanks jvaudry, this is kinda what I suspected. It seems somewhat cumbersome to have to set up a listener for each of the many JTextField's in my form but definitely wrapping all of that up in a class is a good way to go. I'm pretty new to Swing and usually when something seems harder than it should it's a sure sign that I just don't know how to do it right :)
    I may try an altogether different approach just for curiousity's sake. I'm thinking of adding a method to the parent JPanel that will iterate all of its text fields and create a checksum of their combined contents. The idea is that I will compute the checksum once after populating the form and then later to see if any of the fields have changed. A simple notion that may not turn out to be so simple once I get to coding, but it's worth a try.
    Thanks!
    jam

Maybe you are looking for