How do I pass an event up the component hierarchy?

I have a child component which has a mouse listener and a parent component with a mouse listener. However the child component consumes all the mouse events so the parent doesn't get them.
Is there a way for a child component to receive mouse events, then decided to pass them back up the component hierarchy so the parent can still receive them too?
I've spent the last two hours on Google and can't seem to find anything relevant.
Cheers, Eric

Unfortunately, you cannot
override this method since it ispackage-private.
That was wrong of mine. Package-private members are
visible to subclasses too (the package access is a
complete superset of protected access). So you CAN
override dispatchEventImpl and do your stuff there.
When I try that the compiler gives me the following warning
The method SheetElementPlacementComponent.dispatchEventImpl(AWTEvent) does not override the inherited method from Container since it is private to a different package.
It lets me define the method, but does not let me override it.
I just wonder why they made dispatchEvent() final,
when it just calls dispatchEventImpl(), and it is
not final...
Another useful method is Component.enableEvents()
and disableEvents() (which are both protected). You
can use them to modify the so called event mask of a
component, which is used to signify which events a
Component is interested in. Disabled events (= not
on the event mask) are not delivered to the
component and the dispatcher skips it, looking for
parent components which have enabled the event. For
example, if you have a JButton in a scroll pane and
you scroll the mouse wheel on the button, the event
is dispatched to the scroll pane, even though it
occurs over the surface of the button. That's
because a button is not interested in mouse wheel
events.
You can use that hack the following way: In the
mouse listener for your child component, after you
have done your work, disable mouse events for the
component and then post the event again (invoke
dispatchEvent(theEvent)). That way, the event should
be delivered to the closest parent that is
interested in mouse events. This is done
synchronously, so after all listeners for the parent
components have finished, the dispatchEvent() method
returns in your listener for the child component.
Then you re-enable mouse events on the child
component in order to receive the next mouse event.
I don't know if this works or if it has any side
effects, but it's worth a try...I can't call dispatchEvent() because it creates an infinite loop resulting in a stack overflow. It tried calling((JComponent) getParent()).dispatchEvent(e); but this does not help either, the parent never gets the event.
Hope this helps you more :).
Greets,
MikeSorry, I still can't find a way around it other than to redesign my UI.
FYI I created a bug report and Sun have assigned it Bug Id: 6571453. Everyone please vote on this if you think it's a cool feature request.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6571453
Cheers, Eric

Similar Messages

  • How can I pass a value to the command prompt?

    I was wondering how can I pass a value to the command prompt with Windows and Linux? I'm more interested in Linux's system than Windows though. Is there a way to return info from the command prompt?

    Here is a snippet from http://mindprod.com/jglossexec.html that explains how in detail.
    Runtime.getRuntime().exec("myprog.exe") will spawn an external process that runs in parallel with the Java execution. In Windows 95/98/ME/NT/2000/XP, you must use an explicit *.exe or *.com extension on the parameter. It is also best to fully qualify those names so that the system executable search path is irrelevant, and so you don't pick up some stray program off the path with the same name.
    To run a *.BAT, *.CMD, *.html *.BTM or URL you must invoke the command processor with these as a parameter. These extensions are not first class executables in Windows. They are input data for the command processor. You must also invoke the command processor when you want to use the < > | piping options, Here's how, presuming you are not interested in looking at the output:
    Runtime.getRuntime( ).exec ("command.com /E:1900 /C MyBat.bat" );
    Runtime.getRuntime( ).exec ("cmd.exe /E:1900 /C MyCmd.cmd" );
    Runtime.getRuntime( ).exec ("C:\\4DOS601\\4DOS.COM /E:1900 /C MyBtm.btm" );
    Runtime.getRuntime( ).exec ("D:\\4NT301\\4NT.EXE /E:1900 /C MyBtm.btm" );
    There are also overloaded forms of exec(),
    Runtime.getRuntime( ).exec ("command.com /E:1900 /C MyBat.bat", null);
    Runtime.getRuntime( ).exec ("command.com /E:1900 /C MyBat.bat", null, "C:\\SomeDirectory");
    The second argument can be a String [], and can be used to set environment variables. In the second case, "C:\\SomeDirectory" specifies a directory for the process to start in. If, for instance, your process saves files to disk, then this form allows you to specify which directory they will be saved in.
    Windows and NT will let you feed a URL string to the command processor and it will find a browser, launch the browser, and render the page, e.g.
    Runtime.getRuntime( ).exec ("command.com http://mindprod.com/projects.html" );
    Another lower level approach that does not require extension associations to be quite as well set up is:
    Runtime.getRuntime( ).exec ("rundll32 url.dll,FileProtocolHandler http://mindprod.com/projects.html" );
    Note that a URL is not the same thing as a file name. You can point your browser at a local file with something like this: file://localhost/E:/mindprod/jgloss.html or file:///E|/mindprod/jgloss.html.
    Composing just the right platform-specific command to launch browser and feed it a URL to display can be frustrating. You can use the BrowserLauncher package to do that for you.
    Note that
    rundll32.exe url.dll,FileProtocolHandler file:///E|/mindprod/jgloss.html
    won't work on the command line because | is reserved as the piping operator, though it will work as an exec parameter passed directly to the rundll32.exe executable.
    With explicit extensions and appropriately set up associations in Windows 95/98/ME/NT/2000/XP you can often bypass the command processor and invoke the file directly, even *.bat.
    Similarly, for Unix/Linux you must spawn the program that can process the script, e.g. bash. However, you can run scripts directly with exec if you do two things:
    Start the script with #!bash or whatever the interpreter's name is.
    Mark the script file itself with the executable attribute.
    Alternatively start the script interpreter, e.g.
    Runtime.getRuntime( ).exec (new String[]{"/bin/sh", "-c", "echo $SHELL"}";

  • How do i add an event to the calendar of my ipad?

    Just purchased a new IPAD, 1st time user.  How do i add an event to the calendar of my ipad?  i do not have a "+"  symbol.

    Go to Settings>iCloud>Calendar>On then Off. Toggle the on/off setting. If you want to use iCloud with the calendar, leave it set to on.

  • How can i pass a parameter to the query to filter the result of this lookup

    Hello,
    i'm developping a web application with JDeveloper 10.1.2 and JHeadStart.
    i realy need to know how can i filter the lookup (LOV) query result.
    in other word, when i click on the lookup, it show all the row that exist in may data base table.
    what i want is how can i pass a parameter to the query to filter the result of this lookup ?
    Thank you

    Hi,
    have a look if this helps
    http://oracle.com/technology/products/jdev/tips/fnimphius/restrictlovlist/restrictlov.html
    Frank

  • How can I pass environment variables to the child process?

    How can I pass environment variables to the child process? This is what I tried and it didn't work.
         static public void main (String[] args) throws Exception {
              ProcessBuilder b = new ProcessBuilder("java", "-cp", ".", "Child");
              Map<String, String> map = b.environment();
              map.put("custom.property", "my value");
                 b.redirectErrorStream(true);
              Process p = b.start();
              BufferedReader reader = new BufferedReader (new InputStreamReader(p.getInputStream()));
              String line = null;
              while (null != (line = reader.readLine())) {
                   System.out.println(line);
         public static void main(String[] args) {
              System.out.println("The value of custom.property is : " + System.getProperty("custom.property"));
         }and the result is:
    The value of custom.property is : null

    Complete test:
         static public void main (String[] args) throws Exception {
              ProcessBuilder b = new ProcessBuilder("java", "-Dcustom.property=my property value", "-cp", ".", "Child");
              Map<String, String> map = b.environment();
              map.put("custom.property", "my environment value");
                 b.redirectErrorStream(true);
              Process p = b.start();
              BufferedReader reader = new BufferedReader (new InputStreamReader(p.getInputStream()));
              String line = null;
              while (null != (line = reader.readLine())) {
                   System.out.println(line);
         public static void main(String[] args) {
              System.out.println("Property value of custom.property is : " + System.getProperty("custom.property"));
              System.out.println("Environment value of custom.property is : " + System.getenv("custom.property"));          
         }

  • HT2513 how do I schedule daily events in the same sequence

    How do I schedule daily events in the same sequence.

    Hello LeatherneckDevilDog,
    Thank you for the details of the issue you are experiencing with duplicate calendar entries.  I recommend reviewing the following articles to resolve issues with iCal duplicates:
    iCloud: Resolving duplicate calendars after setting up your calendar application for iCloud Calendar
    http://support.apple.com/kb/TS4118
    iCloud: Advanced Calendar and iCal troubleshooting
    http://support.apple.com/kb/TS4337
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • Can we dynamically modify the Component Hierarchy?

    Is it possible to modify the component hierarchy in JSF when making an Ajax call to the server for information?
    I am interested in using Ajax with JSF to update the UI incrementally as needed.
    As an example, imagine a phone book which starts with a list of names. When one clicks on a name, Ajax is used to get the data for that name (i.e., address, phone numbers, etc), and the data is then returned to the client and inserted into the DOM in the client browser under the approprtiate user. This information could be editable. Clearly, as part of this process, I would like the component hierarchy in JSF updated with the new data, also.
    I konw that we could do a complete postback of the entire page plus the new data, and then diff it out on the client (as per the methods outlined by Jacobi and Fallows in Pro JSF and Ajax: Building Rich Internet Components). However, I am wondering if it is possible to update the Component Hierarchy with the new components associated with the new data during the Ajax call, so that we can focus our Ajax request on the needed data only, rather than having to regenerate the entire page.

    Hi wua22,
    For my case, I found that if an attribute called "userPassword" is added in the Schema Manager, after running the above codes which I quoted, it seems that nothing changes since next time when you log on, it can only be authenticated using the old password. However, in this case, actually, the change was made in the ADDED attribute, "userPassword". You'll find where the change made if you have the admin right to check the properties of the users' account using ConsoleOne (or similar tools).
    In addtion, for the exception I encountered in my case, I found that everythings go normally if that ADDED attribute "userPassword" is deleted. So, this time, it's the setting in my LDAP server which caused the problem, but not the programming error.
    BTW, someone suggested that using UnicodePwd attribute, instead of the userPassword for updating one's password. This UnicodePwd attribute is unicode converted. I've not tried on that actually, but will at a later time.
    Hope that helps to you.
    Regards,
    Mercury

  • TS3714 how can i set an event in the calander to repeat on 2nd thurday of every month

    how can i get an event to show in calander every 2nd thursday every momth

    Try the app "Week Cal".

  • How to suppress 'spurious' update events where the entry is identical

    We often have clusters with event listeners on reference data caches. These caches are refreshed by calling putAll() to update values efficiently. Although this is efficient, and keeps refresh code simple, many unwanted 'spurious' update events are generated. Spurious in the sense that in most of update events the old and new values are the same.
    We considered using a MapTrigger to suppress these uninteresting update events. The problem is how to implement a 'veto' in the MapTrigger.process method. What we'd like to do from a trigger is:
    if (old value == new value)
      ignore new entry
    else
      process, enrich, or validate new entry as desired...
    end ifWe'd like a clean way to signal from a MapTrigger that an entry should be ignored (rather than rejected). The Javadoc shows two possibilities:
    *(1)* undo the pending change by resetting the entry value to the original value obtained from MapTrigger.Entry.getOriginalValue();
    *(2)* reject the pending change by throwing a RuntimeException, which will prevent any changes from being committed, and will result in the exception being thrown from the operation that attempted to modify the map
    Of these *(2)* Causes a put() failure in the client. That is appropriate for something like a validation failure, but not for simply ignoring an unwanted update. Option *(1)* unfortunately generates an update event!
    Our current workaround is a MapEventTransformer to suppress the spurious updates:
    public class UpdateSupressionTransformer implements MapEventTransformer {     
      /** Avoid sending an update event if the value is unchanged */
      public MapEvent transform(MapEvent e) {
        if (e.getId() == MapEvent.ENTRY_UPDATED) {
          if (e.getNewValue().equals(e.getOldValue())) {
            return null;
        return e;
    }This works well but requires client code to register event listeners correctly. It also means that the unecessary change is still generated in the cache. For example a cache stores will be called needlessly.
    Can a feature be considered to allow a clean way for identical updates to be ignored, or to not generate events?
    Ideally this would be before the update is made - like a trigger. It seems a pity the MapTrigger design does not allow this.
    Such a feature would allow simple cache refresh logic using putAll() - without having to check for deltas - avoiding large numbers of unwanted update events. We think this is likely to be a common requirement.
    Cheers,
    phil

    Hi,
    I dont think that this is the problem associated with portal.You are working on BI queries in portal but BI screen that you are working on is of SAP R/3 correct me is i am wrong??And the message you are getting is of R/3 screen,BI screens are shown in an iview and an iview cant show any message..
    Regards,
    Ameya

  • How to perform an autocheck event when the field changes in ALV

    Hi everybody,
    how can I build an event or something which would make my 'wa_fieldcat-checkbox' set to 'X' (auto checked) everytime an editable field in the ALV is changed manually by the user?
    I want to perform this task in order to avoid asking the user to manually check the "check box" field everytime wants to make a change, since after the user's changes in the ALV I want to sort the itab with the check box column of the edited items.
    Thanks,
    Denis M

    Hi Denis,
    For ALV a FM REUSE_ALV_GRID_DISPLAY is available.
    The FM, has events as importing option.
    SLIS_T_EVENT
    EVENT - Basically this is the FM to handle Event's. When the user needs to do
    some event operation like when double clicking the a particular field we need to
    perform some operation.   These events are captured by this FM.
    slis_ev_data_changed -- To capture user command
    slis_ev_user_command -- To capture data changed.
    Also please refer the below link in scn. This shows sample code to capture ALV grid data changed.
    http://scn.sap.com/thread/261210
    Hope this will solve the problem.
    Thanks,
    Soundarya.

  • How to trigging a object event which the object type has two key fields

    Hi,kind guys
    I use the object type QMSM about qualification notification task,it has two key fiedls,qualification notification number and task number (can display by t-code -QM03), I want to trigging the event 'create' in  BOR 'QMSM ' by function SWE_EVENT_CREATE(or SAP_WAPI_event_create), but it only has one object key ,
    example:
    CALL FUNCTION 'SWE_EVENT_CREATE'
      EXPORTING
        OBJTYPE                       =  OBJTYPE
        OBJKEY                        =  OBJKEY " only one key
        EVENT                         =   EVENT
    but the BOR object 'QMSM' has two keys,so it cann't be trigged rightly.
    thanks for any help.

    You have to Concatenate the Business object keys and pass it in one variable OBJKEY.
    Thanks
    Arghadip

  • How can I enter an event for the first Monday of every month?

    I used to have a Custom choice that allowed me to select day or date for repeat. Where is it?

    I don't believe there is such a custom repeat option with the iPhone's Calendar app, but if you are syncing calendar events with a supported calendar app on your computer or syncing calendar events over the air with an email account that supports it with an option to create such a custom repeating event with the online calendar, set up the custom repeating event there.

  • How can I pass a path to the FileReference upload function?

    i don't understand how can i upload a file from the browse
    function after you've selected a file. since FileReference.name
    returns
    only the filename w/extension and not the path, how can i
    work around this?
    i understand the security implications with a swf and the
    such, but what to do? and using an AIR app is not an option for me.
    i have a .net web service in place and it works with a hard
    coded string, such as in the snippet below, but how are people
    doing this by using the browse method as oppossed to a static
    string?
    i get an IO error with just the browse() returned filename,
    which makes sense when you think about it. path, path, path...ARGH!
    thanks folks...
    -fd

    i don't understand how can i upload a file from the browse
    function after you've selected a file. since FileReference.name
    returns
    only the filename w/extension and not the path, how can i
    work around this?
    i understand the security implications with a swf and the
    such, but what to do? and using an AIR app is not an option for me.
    i have a .net web service in place and it works with a hard
    coded string, such as in the snippet below, but how are people
    doing this by using the browse method as oppossed to a static
    string?
    i get an IO error with just the browse() returned filename,
    which makes sense when you think about it. path, path, path...ARGH!
    thanks folks...
    -fd

  • How to throw and handle event defined in component interface

    Hi folks,
    I have defined a component interface with an event 'open_info'
    I have some sub components which are implementing that component interface. I also get the two events generated (the interface check box is not marked)
    I use those sub components and try to handle the event. but unfortunately the event is not handled.
    I'm not sure if I do everything right. I checked the interface checkbox at the events tab of the controller of the sub component. I then may handle the event in the embedding main component. but it appears to be a different event.
    probably I eed to access the interface controller and throw the event there, but I don't know how.
    I couldn't fnd documentation or wdr* components which deal with that issue. do you have any suggestions?
    regards
    stefan

    Hi Stefan,
    Do the following in the component being used:
    say component name is ZCMP_01
    go to COMPONENTCONTROLLER
    Create an Event with necessary parameters if needed, say Event name is EVNT_01 and has an importing parameter, say PARAM_01 type char10,
    Make sure you have set the interface check box. Now this event is available in the INTERFACECONTROLLER.
    Say ZCMP_01 has a view with a button, on click of the button, call a method in the COMPONENTCONTROLLER.
    Perform all the required operations, At the required point, fire EVNT_01
    wd_this->fire_EVNT_01_evt(
          PARAM_01 = 'sample' ).
    Now the other component that has to use ZCMP_01, say ZCMP_02
    In the component properties od ZCMP_02, add usage for ZCMP_01, say USG_CMP_01
    Go to the view in ZCMP_02 where you wish to handle the event EVNT_01 of ZCMP_01,
    Go to Methods tab, create an event hadler, say EVNT_01_HNDLR ... method type = Event Handler,
    Event = EVNT_01, Controller = INTERFACECONTROLLER, Component Use, USG_CMP_01.
    Now your event handler will have foll parametrs: WDEVENT .. type ref to CL_WD_CUSTOM_EVENT,
    PARAM_01 type CHAR10
    Handle the event as required.
    Regards,
    Reema.

  • Passing an event up the chain question

    Hello everyone
    I kinda new so please bear with me :)
    I have a class "pnl" that extends a JPanel and handles its own mouse events
    within this class I am adding instances of another class("lbl" : extending from JLabel) that also handles its own mouse events
    what I want is if I press a modifier key and click on the lbl instance, I want the event to be passed up the to its parent , the pnl class.
    is that possible? How?
    bisher

    There are a few ways that you can do it. The easiest way would be to add a method on "pnl" to set whatever variable you want to pass to it, then from the "lbl" class you can call that method and set the value. Or you can take a look at the Observer and Observable classes, they let you send messages from one class to another where it can be handled.

Maybe you are looking for

  • Get access to a value in a running while (with C++)

    Good morning, I have a serious problem. I run a Vi with a while loop (for acquisition). In this loop, there are many values. I want to access to them while the loop is running. The problem of my VI is it does not give me the value until the loop has

  • ITunes slow, "Do not disconnect" and freezing - how I fixed it

    Ok, I don't know how many people this might help but I thought I would post how I managed to fix my iTunes. I was experiencing various problems. Firstly, when starting up iTunes it would just give hourglass, stop, then boot up the program 1 minute la

  • Project planning board report to microsoft project report

    hi all good morning i want to convert the project planning board report to Microsoft project and primavera report ... please guide me through the steps...... Thanks in advance Surya

  • Guest users in EP.

    Hello friends, I have EP 7.0 SP13. Whenever I restart J2EE engine, I see guest users gets logged in on each server node.Could you please provide me with details what this guest users? How can I prevent guest users from loggin into all the nodes. Than

  • Newbie question: Can't change my number in Settings

    Apologies if this has been raised before, I'm new to iPhones and I brought my old number into a new provider and it works fine, but in Settings/Phone/My Number the old number is shown there and does not seem editable. Is there a solution to this? Tha