Is it possible to call keyPressed event manually?

I have a jButton and have added a KeyListener as below
JButton jb = new JButton ();
jb.addKeyListener(new KeyAdapter() {
     public void keyPressed(KeyEvent evt) {
          bKeyPressed(evt);//My own function
});I just wanted to know how to call the function keyPressed manually. I know that this function is called every time a key is pressed when jb is at focus. But i want to call it via program with my own character, say '1' or 'A' etc., that is via completely thru code. ie., create a effect that a particular char is pressed. Please help..

There may be an easier way, but if all else fails, see [Robot.keyPress(int)|http://java.sun.com/javase/6/docs/api/java/awt/Robot.html#keyPress(int)].
Edit 1:
Speaking of 'easier' see [AbstractButton.doClick()|http://java.sun.com/javase/6/docs/api/javax/swing/AbstractButton.html#doClick()].
Edited by: AndrewThompson64 on May 24, 2009 7:50 PM

Similar Messages

  • How can i call mouse click event from keypress event???

    How can i call mouse click event from keypress event???
    I want same GUI changes to be occured at key press.....i.e . button going down & comming up.....
    for calculator

    Put all the code that happens on those events into a method. Then call that method from both events.

  • Is it possible to save an Event and the informations attached to his medias (favorites, Keywords, Notes) on an external disk where I saved the first version of this Event, without re-copying the all medias on a new Event called fcp1?

    Is it possible to save an Event and the informations attached to his medias (favorites, Keywords, Notes) on an external disk where I saved the first version of this Event, without re-copying the all medias on a new Event called fcp1?

    If they both have the same media, you can just copy the CurrentVersion.fcpevent file.  But then you have two databases with the same UUID, and FCP X will only open one of them.  If you use Carbon Copy Cloner, you can clone just that folder to the external drive, and set it up to only update files that are newer or have changed.

  • Adf javascript clientlistener not capturing the TAB keypress event

    Hi,
    I have client listener attached to a text field to trap the keyPress event. The method is being called for all the key strokes except special keys like TAB, arrow keys, pageup, pagedown etc. Is there any possibility to capture TAB key event.
    <af:clientListener method="myFunctionTosetFocus"
    type="keyPress"/>
    function myFunctionTosetFocus(event) {
    alert('function called....')
    var keyCodePressed = event.getKeyCode();
    if(keyCodePressed == AdfKeyStroke.ENTER_KEY || keyCodePressed == AdfKeyStroke.TAB_KEY) {
    alert('Do some thing here....')
    I can see both the alert messages when I click on the ENTER key. But I cannot see both the alert messages when I cick on TAB key. The same is working without any problems in firefox.
    Thanks and Regards,
    S R Prasad

    Hi Frank,
    I tried with the event.cancel(). Now I can see the event.cancel() working for ENTER key, But not for the TAB key. I tried with the keyDown event in the clientListener and it is working with out any problems in both IE and firefox.
    It is not working as expected in case of keyUp event, If I set the focus to the next tab in the clientListener code, it is executing the clientListener of the destination component if the clientListener event is keyUp.
    Overall it is wotking as expected with the keyDown, But it is not working for the keyUp and keyPress events. All these are working as expected in firefox.
    Thanks and Regards,
    S R Prasad

  • Is it possible to call a VI that is inside a LabVIEW executable from a TestStand sequence?

    I have created a custom TestStand operator interface and have modified the default sequential process model to display a UUT information dialog that prompts for more information than just the UUT serial number.  This UUT information dialog is a LabVIEW VI.  To distribute the operator interface, I build it into an executable.  As part of the build process, I make a copy of the UUT information dialog VI (which is part of my operator interface project) and place it in the same folder as the executable.  I have then configured the sequential process model to call the dialog VI from this location.  It would be really nice if I could embed the UUT information dialog VI inside the operator interface executable so that I could distribute just an executable instead of an executable and separate VIs.  Is this possible?  In other words, is it possible to call a VI that is inside a LabVIEW executable from a TestStand sequence just like a standard LabVIEW VI call?

    Ryan,
    The dialog that you've created isn't being directly called by the OI at all and shouldn't need to be included in the same directory as the OI for distribution. Since you are modifying the PreUUT of the default process model, you will give the path to the VI in that step, create a deployment and then manually copy the VI to the directory referenced in the step. The VI is considered a support file for the process model and is not related to the OI at all.
    Test Engineer - CTA

  • Calling Portal event from ABAP class

    Hi Experts,
    I need a following clarificatrion, Please help,
    1. Is it possible to call a webdynpro method from a normal ABAP class?
    2. If no, we need a functionality of a class 'CL_WDR_HTTP_EXT_MIME_HANDLER' having method 'DO_DOMAIN_RELAX_HTML'.
    Is there any alternative method which can be used in ABAP having the same functionality.
    3. Is there any ways with which we can call portal event from ABAP class?
    Thanks,
    Shabir

    >1. Is it possible to call a webdynpro method from a normal ABAP class?
    I wouldn't necessarily recommend this approach. You shouldn't try to trigger events or any of the standard WDDO* methods from outside the WD Component itself.  That said, you can pass the object reference (like the WD_COMP_CONTROLLER object reference or the View Object Reference) into methods of normal classes.  Be careful if you are finding yourself calling a lot of your added methods from outside WD.  This is probably a sign that these methods should be in the Assistance Class or some other Class functioning as a Model Object.
    >2. If no, we need a functionality of a class 'CL_WDR_HTTP_EXT_MIME_HANDLER' having method 'DO_DOMAIN_RELAX_HTML'.
    Is there any alternative method which can be used in ABAP having the same functionality.
    What exactly do you want to do here?  Do you just want to get the relaxation script?  For what purpose?  You should never need to inject the relaxation script into WDA. 
    >3. Is there any ways with which we can call portal event from ABAP class?
    To what purpose.  Do you just want to delegate the triggering of the event that is inside WD Component to be called from a class?  If so you can pass the portal API object reference into a class from the WD Component.  However this only works while running within WD.
    How is this class used?  Are you running in WD?  Are you trying to generate some HTML code that runs in the portal independent of WD?

  • Keypress Events

    Hi, everybody, it is my first question to you all.
    Does anybody have any function that would capture keypress events, or
    any information that would be helpful in capturing them? For example,
    when a user presses the <down arrow> or F1 key. I am currently using
    the AfterValueChange event to capture keys that display.
    Thanks,
    Scott Watters
    Systems Analyst
    Carlson Wagonlit Travel - Minneapolis
    [email protected]

    Hi, Scott.
    Here's the information I found on trapping keystrokes - mostly R3 =
    specific, but that's OK for you. I pulled the following posts off my =
    mailing list archive:
    From: <[email protected]>
    Date: Fri, 4 Apr 1997 15:57:32 +0800
    Subject: Trapping Certain Keystrokes
    Hi All,
    I have read the manuals, and the online-documentation, but can not seem =
    to find anything about trapping keystrokes other than the Function keys.
    Our application specifically requires us to trap certain keystrokes, =
    such as the navigation keys etc.=20
    Does anybody know which event is raised when a key is pressed?
    Any insight will be appreciated.
    Regards Martin
    From: DEVEAUX Manuel <[email protected]>
    Date: Fri, 4 Apr 1997 11:43:11 +0200
    Subject: RE: Trapping Certain Keystrokes
    Hi all,
    Actually, I don't think you can trap keystrokes on a UserWindow but on =
    some WidGets (like DataFields), you can set to TRUE the 'Validate on =
    KeyStroke' option in the properties dialog .
    Thus, when the WidGet has the focus and the user send a keystroke, you =
    can trap this event with the 'AfterValueChange' event. If someone knows
    =
    how to trap keystrokes on a UserWindow, I am also interested !
    Thanks.
    * Manuel -
    Manuel Deveaux
    Fort=E9 Developer
    Mutuelle Pr=E9viade
    Nancy, FRANCE
    E-Mail : [email protected]
    From: Jean-Paul De Baets <[email protected]>
    Date: Fri, 04 Apr 1997 14:11:58 +0200
    Subject: RE: Trapping Certain Keystrokes -Reply
    This is an enhancement request we also posted several months ago. I =
    think it is announced for Fort=E9 release 3. But I don't know if we =
    will be able to trap ANY keystroke.
    Jean-Paul=20
    J.P. De Baets
    CAP GEMINI Belgium
    [email protected]
    From: Kerry Bellerose <[email protected]>
    Date: Fri, 04 Apr 1997 13:28:14 +0100
    Subject: Re: Trapping Certain Keystrokes
    Hi Manuel and Martin,
    Unfortunately, for Forte V2.0, Manuel is correct. But Forte has added a
    =
    feature that allows you to trap any keystroke in Forte R3, which is =
    currently in beta.
    If you are a beta site, look in the Forte Release 3 Beta Features manual
    =
    page 169, the window class SetAsFunctionKey method.
    If you are not a beta site and want this functionality in R2,=20
    you would need to do some tricks with menus or data fields, as Manuel =
    indicated.
    Cheers,
    Kerry
    From: Lee Wei <[email protected]>
    Date: Mon, 7 Apr 97 09:06:23 PDT
    Subject: RE: Trapping Certain Keystrokes -Reply
    I think all of us want to know if we can indeed trap ANY keys.
    The answer is ALMOST, including escape, spacebar, enter, backspace, tab,
    =
    navigational (up,down,left,right,end,home), digits, alpha, numeric =
    keypads, insert, delete.
    But not keys such as left shift, right shift, left Alt, right Alt, left =
    Ctrl, and right Ctrl (Helpful for games...).
    Don't forget that we are talking about release 3.
    Lee Wei
    Hope this helps,
    Dariusz Rakowicz
    [email protected]
    From: owner-forte-users
    Sent: Friday, July 25, 1997 10:46 AM
    To: 'Forte Users Group'
    Subject: Keypress Events
    Hi, everybody, it is my first question to you all.
    Does anybody have any function that would capture keypress events, or
    any information that would be helpful in capturing them? For example,
    when a user presses the <down arrow> or F1 key. I am currently using
    the AfterValueChange event to capture keys that display.
    Thanks,
    Scott Watters
    Systems Analyst
    Carlson Wagonlit Travel - Minneapolis
    [email protected]

  • Possibility of calling ALV report

    hi experts,
    i have a requirement that i have to design an entry screen whcih contain pushbuttons (SAVE, CLEAR ,DISPLAY).
    whenever user pressed DISPLAY, he wants to call the selection screen of an alv report which is already exists.
    is that possible to call an alv report selection screen and execute it.
    any suggestions pls.
    thanks&regards
    maheshlap.
    Edited by: Thomas Zloch on Dec 17, 2011 11:07 PM

    Hi,
    Follow this code,
    *DISPLAY DYNAMIC PUSHBUTTON ON APP TOOLBAR ON USER CLICKS
    SELECTION-SCREEN: FUNCTION KEY 1,
                      FUNCTION KEY 2,
                      FUNCTION KEY 3.
    **EVENT ON SELECTION SCREEN FOR OUTPUT DISPLAY
    AT SELECTION-SCREEN OUTPUT.
    *CLICK OF FIRST RADIO BUTTON
      IF pa = 'X'.
        sscrfields-functxt_01 = 'Materials Management'.
        WRITE icon_plant AS ICON TO text_001.
    *CODE TO GET DYNAMICS BASED ON THE SELECTED RADIO
        LOOP AT SCREEN.
          IF screen-group1 = 'MOD'.
            screen-intensified = '1'.
            screen-active = 1.
            screen-display_3d = '1'.
            MODIFY SCREEN.
          ENDIF.
          IF screen-group1 = 'RAD'.
            screen-intensified = '0'.
            screen-active = 0.
            screen-display_3d = '0'.
            MODIFY SCREEN.
          ENDIF.
          IF screen-group1 = 'CAD'.
            screen-intensified = '0'.
            screen-active = 0.
            screen-display_3d = '0'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    *CLICK OF SECOND RADIO
      IF pb = 'X'.
        sscrfields-functxt_02 = 'Sales And Distribution'.
        WRITE icon_ws_ship AS ICON TO text_001.
        LOOP AT SCREEN.
          IF screen-group1 = 'RAD'.
            screen-intensified = '1'.
            screen-active = 1.
            screen-display_3d = '1'.
            MODIFY SCREEN.
          ENDIF.
          IF screen-group1 = 'MOD'.
            screen-intensified = '0'.
            screen-active = 0.
            screen-display_3d = '0'.
            MODIFY SCREEN.
          ENDIF.
          IF screen-group1 = 'CAD'.
            screen-intensified = '0'.
            screen-active = 0.
            screen-display_3d = '0'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    *CLICK OF THIRD RADIO
      IF pc = 'X'.
        sscrfields-functxt_03 = 'Human Resources'.
        WRITE icon_new_employee AS ICON TO text_001.
        LOOP AT SCREEN.
          IF screen-group1 = 'RAD'.
            screen-intensified = '0'.
            screen-active = 0.
            screen-display_3d = '0'.
            MODIFY SCREEN.
          ENDIF.
          IF screen-group1 = 'MOD'.
            screen-intensified = '0'.
            screen-active = 0.
            screen-display_3d = '0'.
            MODIFY SCREEN.
          ENDIF.
          IF screen-group1 = 'CAD'.
            screen-intensified = '1'.
            screen-active = 1.
            screen-display_3d = '1'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    *CUSTOMISING THE TOOLBARS OF THE SELECTION SCREEN
    *WITH F8 BUTTON DISABLED
      APPEND :  'PRIN' TO it_ucomm,
                'SPOS' TO it_ucomm,
                'ONLI' TO it_ucomm.
      CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
        EXPORTING
          p_status  = sy-pfkey
        TABLES
          p_exclude = it_ucomm.
    Warm Regards,
    PavanKumar.G

  • Is it possible to call C++ code from a HTML5 panel?

    I have thousands of lines of C++ code that I need to reuse inside my HTML5 panel for Illustrator. Is it possible to call my C++ functions from within my HTML5 panel? Some kind of wrapper maybe?

    Hi,
    A possible solution is to dispatch CSXS events from your HTML panel, and listen to those events in your C++ code and then execute your C++ code.
    Hui

  • Is it possible to call a Crystal Report from Oracle Forms.

    Hi Everybody,
    I got a Dout about Crystal Reports. Is it possible to call Crystal Reports from Oracle Forms.

    Hello,
    That depends are you running Forms via the WEB or client/server. I will assume you are running client/server since you are running crystal reports. The answer is yes. All you will have to do is use the HOST command or the win_api_shell to run the report. Look in the Forms manual for information on the commands and what else you may need.
    John

  • Is it possible to call any Managed Bean method from af:goLink

    Hi,
    I am using RichGoLink component.
    Is it possible to call a managed bean method on click of the af:goLink? I want to provide some validations when user clicks on the goLink.
    There is no any actionListener provided.
    Thanks in advance.

    Hi,
    I am able to resolve my second problem also.
    i wanted to set the "destination" of the goLink on the fly. To do this I created a custom componnt by extending the RichGoLink and I override the encodeBegin method in that class. In this method i check my condition and then set the "destination" property.
    I am still using the clientListener and the serverListerner to do some further testing that i wanted to. Here one thing you have to keep in mind that. In the javascript function that we are calling in the clientListener should not do the "cancel" on the event object, if you do so it will not navigate to the required position.
    Thanks for the way you showed to resolve my problem. Hope you understand the way i worked for this solution.

  • Is it possible to restore deleted events?

    Is it possible to delete calendar events to some kind of trash folder which allows me to restore event if I accidentally deleted it?
    As a workaround I currenlty use separate so called "Trash" calendar, but it is not always convenient.
    Two examples follow when "Trash" calendar is not conventient:
    Example 1. I want to delete event in advance which has notification set up. Deleted event to "Trash" calendar will emit notification, which is not what I expect.
    Example 2. Deleting one event from recurrent event series. "Trash calendar does not work at all.
    I use iCloud Calendar on Mac OS X and iOS devices.

    No, unfortunately once you delete a backup you can't get it back.

  • Listening for keyPressed events from background?

    Is it possible to have a java program running in the background and listen for keyPressed events? I would like for the program to listen for certain keys to be pressed and when they are manipulate the mouse. From what I've looked at so far however it seems the listening component must have focus. Thanks.

    On any OS that would typically involve hooking into the OS itself.
    And then manipulating OS resources as well.
    Putting an app into the 'background' is also OS specific.
    Given that the above is all you want to do then java is not an appropriate language choice. C++ would be better.

  • Can one get keyPressed events anywhere other than in Canvas?

    Hi there,
    I have a form displayed
         display.setCurrent(form);
    but I would like to receive keyPressed events, in particular "game actions" UP DOWN LEFT RIGHT.
    As far as I can tell, this isn't possible unless I have a Canvas displayed. :-(
    The form is displaying data (a couple of string items) and the soft key commands.
    This is only my second MIDP app, so any help would be appreciated.
    Thanks,
    colin

    1. Don't know.
    2. Hopefully you have a backup to restore from. Contacts are separate from iTunes, but if you enabled iCloud, then your contacts should be preserved (if you do not use Outlook, Address Book, etc.)

  • KeyPressed Event in Swing

    In keyPressed Event Iam calling dispatchEvent on the component passing the ActionEvent as argument.
    Iam expecting that, control should come back to actionPerformed as it happens in awt.
    But, it is not behaving like that. Can u guys figure it out Y??
    Here is my sample code:
    public void CancelButtonPressed () {
    ActionEvent actionEvent = new ActionEvent((Object)CancelButton,
         ActionEvent.ACTION_PERFORMED, CStrings.CANCEL);
    CancelButton.dispatchEvent (actionEvent);
    Note: CancelButton is my JButton object instance.
    Iam expecting that after dispatchEvent is called as above java should invoke actionPerformed.
    But it is not.

    I need to construct ActionEvent explicity since actionlisteners are set for the components in one class say A.
    From this class keypressed event is delegated to the other class say b.
    Here B class gets the component. Inour case its JButton. In class B, i cannot call the actionPerformed.
    What I do is.. I will call the dispatchEvent on this component. Thats why Iam creating ActionEvent.
    I hope you got my point.

Maybe you are looking for

  • Problem in activating substitution in workflow,

    Hi Friends I've maintained my substitute from sbwp. whenever i'm getting a workitem ,a similar copy is being receiped by my substitute. But actually I want that only my substitute will get the workitems, not me for the time period mentioned in substi

  • Reverting back to Itunes 7.4.3.1

    PROBLEM: I had issues with Itunes 7.5 on my laptop (IE Itunes 7.5 wouldn't run at all!) and found very little in the form of direct plain instructions available anywhere that would help my issue. SOLUTION: So I did a date restore on my laptop to a da

  • How do I uninstall iTunes from my Mac book Air

    My wife gave me her Macbook Air and I want to install my own iTunes on it. How do I uninstall my wife's iTunes?

  • How to write java code to read the pixel color in some place of screen?

    Hello all: How to write java code to read the pixel color in some place of screen? The java application iteself doesn't have any GUI. thank you -Danel

  • Verizon On Demand -- maintenance outages

    Couldn't sleep at 3 a.m. so I figured I'd scroll through VOD to watch a movie.  It didn't work.  I called and after 20 minutes of waiting for tech support, I was told that VOD could be out anytime between midnight and 6 a.m. for maintenance.  When I