How to implement "ALT + some key" event ?

Hello,
I'd like JDialog to catch key events only when user holds ALT button and presses some regular key (e.g. A,B,C, etc...).
How this can be done ?
Thanks for any advice !

maybe you should use mnemonics?
i don't know what is it you want to do.
buti if you want for example to have JDialog, where are some buttons (OK & CANCEL) and want user to be able to click them by pressing ALT+O or ALT+C, then you might need to use mnemonics...
if you want to enable some new kind of copy/paste/whatever combinations, then you might want to use keybindings
http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html
or see tutorial about using menus, and the part there which tells about enabling key operations
http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html#mnemonic
or be more specific about your problem... what and Why are you trying to do.

Similar Messages

  • Macbook misses some key events for a few seconds

    I have noticed that for last two months or so something strange happens to my Retina MBP. Once in a couple of days it stops responding to some key events. It is like it handles only one keypress out of 4-5. Nothing seems to be wrong with the keyboard and it is not about a particular key or keys. And about 10-15 seconds later everything goes back to normal. I do not see any suspicious messages in the logs, the computer is connected to the power supply...It happens just by itself in the middle of the day, when I am typing.
    Almost looks like some interrupts get lost by the system while it is busy with something else. But I have checked the load level and running processes - nothing interesting there....And whatever it is - it happens during a very short period of time.

    Hi,
    No, I have not returned my MBP yet. In fact, I would rather avoid doing this unless I am convinced if it is a hardware issue. And I do believe it is not. Just recently I have spent some time investigating it and I have found very stroing correlation between the moments when this happens and these messages in the kernel log:
    Jan 13 10:49:54 mbp-wifi kernel[0]: Sandbox: sandboxd(96471) deny mach-lookup com.apple.coresymbolicationd
    Jan 13 10:54:31 mbp-wifi kernel[0]: Sandbox: sandboxd(96499) deny mach-lookup com.apple.coresymbolicationd
    Jan 13 10:54:31 mbp-wifi.home sandboxd[96499] ([96497]): mdworker(96497) deny mach-lookup com.apple.ls.boxd
    Jan 13 10:54:31 mbp-wifi.home sandboxd[96499] ([96498]): mdworker(96498) deny mach-lookup com.apple.ls.boxd
    Jan 13 10:56:32 mbp-wifi.home sandboxd[96504] ([96503]): mdworker(96503) deny mach-lookup com.apple.ls.boxd
    Jan 13 10:56:32 mbp-wifi.home sandboxd[96504] ([96502]): mdworker(96502) deny mach-lookup com.apple.ls.boxd
    And I have also noticed that my Spotlight database gets reconstructed too often, which means it gets corrupted.
    From all this I conclude that it is most likely the software issue and it seems to be linked to spotlight. I saw people reporting similar things. So now I am researching on how to fix it without disabling the spotlight.
    In general, I believe that the quality of Apple software is going down, it is not like 4-5 years ago And Apple does seem to care less and less about it.
    If in your case it happens all the time, not just once in a while, and you see that a particular key has problems - it is possible that we are talking about the different issues and yours might be really about the keyboard.

  • How to implement exist some x, all x these higher order logic in F#?

    http://www.cl.cam.ac.uk/~mjcg/OGI/Notes/HOL.pdf
    how to implement exist some x, all x these higher order logic in F#?
    where can find the example of open source code have these implementation?
    computing nightmare

    i do not know the whole code.
    i just imagine all x  is just a full one in logic table
    i guess that there are two cases
    for example,
    case 1
    Or(All x, B) 
    1 0 -> 1
    1 1  -> 1
    1 0 -> 1
    1 1 -> 1
    case 2
    All x such that B and C
    v x And(B, C)
    And(Or(v x , B), Or(v x, C))
    1 0      
    1 1
    1 0
    1 1
    becomes
    1
    1
    1
    1
    but all these just my guess, i still do not know how all x works in logic table
    is there open source example code in github show all x and exist some?
    exist some in logic table
    0   or    1  or  1  or 1 
    1          0       1      1
    1          1       0      1
    1           1      1       0
    computing nightmare

  • How to send Remote controller key event

    Hi Sir,
    Can anyone tell me "how to send key event from "Remote
    Controller" to Flex application?
    for example. I want to control the Flash player or my Flex UI
    application from remote controller such as use firefly
    controller/streamzap controller/Gyration controller. Normally user
    will use mouse or keyboard to enter/generate event, now I want to
    use "Remote controller" to generate the key event. In Flex, how can
    I capture the key event from "remote controller"? Any sample code
    to provide that will be good.
    Thanks.
    Lin

    Here's a couple related threads
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=583877
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=712386
    I'd also suggest exploring the Search Forums available on the left,
    which is how I found those threads:
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=focus+traversal+tab+text&subCat=siteforumid%3Ajava57&site=dev&dftab=siteforumid%3Ajava57&chooseCat=javaall&col=developer-forums

  • How to trap ALT-Space key combo. ?

    Hi,
          Does anyone know how to trap Alt-space?  The user is probing a PC board and may want to keep their eyes on the work.  The space-bar makes a nice big "next" button, and the Alts on either side seem a natural choice for "back".  But, when I try to trap the Alt-key/space keyboard-event, the program nevers sees it.  Instead, a file dialog is displayed, as if Alt is trapped by the VI-menu-bar - which isn't even displayed!
    Cheers.
    When they give imbeciles handicap-parking, I won't have so far to walk!

    I believe Alt-Space is a keyboard shortcut in Windows XP to bring up the window menu for any app...so it's not just a LabVIEW thing. Further, it appears that Windows grabs that key combination before a LabVIEW event structure can get it.  I don't know any way around this behavior, since Windows appears to be taking matters into its own hands with certain key combinations.  My advice would be to use a different key combination for your app.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • How to handle Shift+Tab key event

    HI,
    This is Ramesh.I have added KeyListener to JTable. I am handling key events through key codes. But I am
    unable to handling multiple key strokes like Shift+Tab
    Can any one please give me suggestion how can I do it
    Thanks & Regards
    Ramesh K

    i dont know about Key BindingsWhich is why you where given a link to the tutorial in the first response.
    can you please give me suggestion.You've been given the suggestion 3 times. You can decide to learn to write code the way other Swing components are written. Or, you can do it the old way. The choice is up to you.

  • How to disable the F4 Key Event?

    Hi Guys,
    I have written my own FocusManager which allows me to traverse through disabled components. If a user presses the F4 key while the focus is in a disabled JComboBox, the popup becomes activated. Is there any way deactivate the F4 keystroke?
    I have tried:
    event.consume();
    combobox.setPopupVisible(false);
    combobox.hidePopup();
    I also read that F4 is a low-level event maintained by Windows. Is this true? Is there no alternative?
    -Sri :)

    To anyone who may be interested:
    I have tried all available solutions:
    1. hidePopup()
    2. setPopupVisible(false)
    3. unregistering the F4 key event
    4. catching the F4 key event and snubbing it
    I have had no luck with the above solutions. It leads me to believe that F4 key is registered under the windows environment and it is a low-level event.
    -Sri :)

  • How to implement boolean comparison and event structure?

    Hello all,
    I'm currently developing an undergraduate lab in which a laptop sends out a voltage via USB-6008 to a circuit board with an op-amp, the voltage is amplified, and then sent back into the laptop. The student is going to have to determine an "unknown" voltage which will run in the background (they can do this by a step test, graph V_in vs V_out and extrapolate to the x-axis).
    Currently, I have two loops that are independent in my VI. The first loop is used to "Set the zero." When 0 voltage (V_in) is sent out of the laptop it returns a value around -1.40V (V_out) typically. Thus, I created the first loop to average this value. The second loop, averages the V_out values that come into the laptop as the V_in numeric control changes. Then I take the "set zero" value from the first loop and subtract it from the second loop average to get as close to 0V for V_out when V_in is 0V.
    The problem I'm facing is, the event structure waits for the V_in numeric control value change, but after "SET ZERO" is pressed, if there is an unknown value, it will not be added to the average for V_out until V_in is changed by the user. So, I tried implementing a comparison algorithm in the "[0] Timeout Case." This algorithm works for step tests with positive values for V_in, but there are two problems.
    1) Negative values cannot be used for V_in
    2) If a user uses increasing positive values for V_in there is no trouble, but if they try to go back to 0, the value change event has been called and it is added to V_out as well as the timeout case.
    Sorry for the extremely long post, but I've been banging my head over this and can't figure out how to properly implement this. I'm using LabVIEW 8.0.
    Attachments:
    Average Reset Test.vi ‏371 KB

    OK you have bigger problems than Raven's Fan is pointing out.
    When the first event loop stops ( after pressing "") (the boolean text is "Set Zero")  The second loop may start- (AND PROCESSES all of the events it was registered to process before the loop started!)  that would enclude the value change event from "" (The boolean text is Stop) Being pressed bebore the loop started.  Of course, since the labels of "Set Zero" and Stop are identical nulls....................................................BOTH event trigger at the same time and are processed as soon as the event loop they are registerd to is available.
    Get it ... The two buttons labeled "" both queue Value change events to both loops registered to act on the value change of the control labled ""!
    Both loops will do what you programmed in the case of "" Value Change!  This can, (as you have observered) lead to confusing code actions.
    Do avoid controls with duplicate labels (There is a VI Analizer test for that!)  Do avoid multiple event structures in the same hierarchy. 
    DO NOT bring this to your studients to help you learn LabVIEW!  We get enough studii asking embarassing questions
    VI Analizer will help you provide sound templates.  If you need help with that hit my sig line- e-mail me and I'll always be willing to help.
    Jeff

  • How do you identify a key events source (std keyboard or a USB barcode reader emulating keyboard)?

    I have attached a USB barcode reader which essentially emulates a USB
    keyboard. Having looked through the VC++ V5.0 documentation and some SDK
    documents that I have, I could not find a library function that identifies
    what device sourced the keyboad event.
    Does know if this is possible ? Anyone have any ideas ?
    Thanks.

    If you over ride the "CWnd:reTranslateMessage" function you'll be able to trap keyboard messages.
    ex:
    BOOL CTestexecDlg:reTranslateMessage(MSG* pMsg)
    if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == 13 || pMsg->wParam == VK_ESCAPE))
    // Enter or escape key was pressed; return TRUE to stop default handling
    return TRUE;
    if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 0x30)
    BringWindowToTop( );
    return TRUE;
    if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 0x31 && m_DisplayObject1 != NULL)
    // Enter or escape key was pressed; return TRUE to stop default handling
    m_DisplayObject1->SetWindowToTop( );
    return TRUE;
    if (pMsg->message == WM_KEYDOWN && pMsg->wPa
    ram == 0x32 && m_DisplayObject2 != NULL)
    // Enter or escape key was pressed; return TRUE to stop default handling
    m_DisplayObject2->SetWindowToTop( );
    return TRUE;
    if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 0x33 && m_DisplayObject2 != NULL)
    // Enter or escape key was pressed; return TRUE to stop default handling
    m_DisplayObject3->SetWindowToTop( );
    return TRUE;
    return CDialog:reTranslateMessage(pMsg);
    Steve

  • I use Time Machine to back up my iMac.  How can I copy some iPhoto events from my external hard drive to my MacBook?

    I back up my iMac on my external hard drive.  When trying to copy the iPhoto Library onto my MacBook, I get the message "Cannot use TM backup as main library".  I don't even see an option to choose certain Events to copy.  Is there any way I can choose particular Events in iPhoto to copy to my MacBook?  How can I get the photos on my MacBook?

    If you're on Leopard or Snow Leopard, or Lion with iPhoto '08 or earlier, see the gray box at the end of Time Machine - Frequently Asked Question #15.
    If not, you cannot restore individual photos; just the entire iPhoto library.  A workaround is to restore it to an alternate location, such as your desktop, then export the selected photos from there.  See the pink box in the same article.

  • How to implement "press any key to continue",please help

    my problem is when the "press any key to close the dos" has displayed in the dos , how can realize to close the dos when i press any button.
    i have try to use system.in.read();but this method doesn't end until i press the "enter"button.

    public class P {
         public static void main(String[] args){
              System.out.println("XXX");
              System.out.println("press any key to close!");
    //want to System.exit(0) when user type the any key.
              BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
              try {
                   int ch = stdin.read();
                   if(ch !=-1){
                        System.exit(0);
              } catch( Exception e ){
    i run this programe by wrote "java P" in the XXX.bat
    Edited by: azhi on Mar 4, 2008 5:23 AM
    Edited by: azhi on Mar 4, 2008 5:29 AM

  • How to make the TAB Key Event called

    Hi ,
    I want to make the tab key called twice when I hit on a button. It should jump to the next 2 cell.
    Thanks.
    DT

    Here's a couple related threads
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=583877
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=712386
    I'd also suggest exploring the Search Forums available on the left,
    which is how I found those threads:
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=focus+traversal+tab+text&subCat=siteforumid%3Ajava57&site=dev&dftab=siteforumid%3Ajava57&chooseCat=javaall&col=developer-forums

  • In ALV display model ,how to accept the ENTER key event?

    Dear All,
    I have used ALV by  GRID DISPLAY model ,not class model.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = sy-repid
          i_callback_pf_status_set = 'SET_PF_STATUS'
          i_callback_user_command  = 'USER_COMMAND'
          i_structure_name         = 'T_ITAB'
          is_layout                = gs_layout
          it_fieldcat              = t_fieldcat[]
          i_default                = 'X'
          i_save                   = 'A'
        TABLES
          t_outtab                 = t_itab
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
    For example :
    IN ALV DISPLAY, there are two fields, one is MATNR, the other is MAKTX.
    When user input the material value in MATNR field and press ENTER, then ALV can run my code to select the MAKTX into MAKTX field and display it synchronization.
    Now I have realized update edit in ALV,but I found only I double click ALV row, then the MAKTX can update.
    Please give me help,
    Thanks
    Sun

    This is the document written by me on Interactive ALV.. hope this maybe helpful for u..
    When an Interactive Report is needed in Classical Display, we go for AT LINE-SELECTION. But when the same is needed in ALV Display, this method won't work. Instead, we need to use other way which is explained below:
    We use REUSE_ALV_GRID_DISPLAY for ALV Display. Now, normally we call that FM in the following way:
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program      = 'PROGRAM_NAME'
                it_fieldcat             = tb_fieldcat
           TABLES
                t_outtab                = tb_output.
    When it is needed to get an Interactive ALV, call the same FM in the following manner:
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program      = 'ZTEST75599_1'
                it_fieldcat             = tb_fieldcat
                i_callback_user_command = 'USER_COMMAND'
           TABLES
                t_outtab                = tb_output.
    Now, in the report, create a subroutine with the name USER_COMMAND as follows:
    FORM user_command  USING p_ucomm    LIKE sy-ucomm
                             p_selfield TYPE slis_selfield.
      CASE p_ucomm.
        WHEN '&IC1'.   " &IC1 - SAP standard code for double-clicking
    Based on the requirement, write the logic                          *
      ENDCASE.
    ENDFORM.
    No need to call the subroutine as PERFORM user_command. This will be takane care by REUSE_ALV_GRID_DISPLAY. We need to just write the subroutine in the report. That suffices.
    Some more useful points for Interactive ALV:
    1. If Hotspot is needed, then that should be done by declaring hotspot (one field in slis_t_fieldcat_alv) as 'X' in tb_fieldcat which is of type slis_t_fieldcat_alv. When hotspot is active, single click will be enough or else you should double click on the output data.
    2. In Classical Display, when it is needed to read the record on which we double clicked, we do that in following way:
       AT LINE-SELECTION.
           GET CURSOR LINE wf_line. " wf_line gives the line number on which it has been clicked
             READ LINE wf_line OF CURRENT PAGE.
      But this won't work for ALV. Instead, the following logic can be used:
    FORM user_command  USING p_ucomm    LIKE sy-ucomm
                             p_selfield TYPE slis_selfield.
      CASE p_ucomm.
        WHEN '&IC1'.   " &IC1 - SAP standard code for double-clicking
          READ TABLE tb_output INTO wa_output INDEX p_selfield-tabindex.
          IF sy-subrc EQ 0.
    Based on the requirement, write the logic                          *
          ENDIF.
      ENDCASE.
    ENDFORM.

  • Prevent application from grabbing some keys.

    I have media keys for volume control on my keyboard and use them. I have mapped them with KDE hotkeys control module. All work fine. However, some applications, for example, SDL-based ones, grab all keyboard input, including media keys. I lose ability to change audio volume until I stop the application.
    The question is: How can I protect some keys from being grabbed by applications? I mean, how to make sure that some key events always reach target app, even when another app tries to grab all input. For example, Ctrl-Alt-F1 still works in all apps. Is there X server config to protect another key?
    Last edited by Barafu Albino Cheetah (2011-09-16 20:20:31)

    I've made two AUR packages for this:
    https://aur.archlinux.org/packages.php? … _Search=Go
    I'm just using libx11-nokeyboardgrab now, so I let the sdl one go unmaintained.
    libx11-nokeyboardgrab is incompatible with dmenu (edit: and password screensavers), but works with everything (also dialog pop-ups).
    sdl-nokeyboardgrab doesn't grab non-sdl programs (Virtualbox, maybe Wine, I haven't tested it).
    It doesn't prevent mouse grab, because that's necessary for FPS games and Virtualbox mouse mode.
    I have thought of adding in a mechanism where the mouse is only grabbed on some condition. Like the existence of a "/tmp/grabmouse" file. But I've been fine without it.
    One problem that occurs even with mouse grab enabled is that when the game loses focus, it loses the mouse grab too. When you switch back to the game, you need to do something to make it re-grab the mouse.
    For instance in Urban Terror (FPS), when you switch back to the game, the mouse behaves erratic until you press ~ for Console (which normally ungrabs the mouse) and then press it again.
    Last edited by Procyon (2012-01-23 20:14:08)

  • Something is eating my key events!

    Okay, so I am trying to add some key events to a game. I have added this listener to a class I called Background:
              this.addKeyListener(new java.awt.event.KeyAdapter() {
                   public void keyPressed(java.awt.event.KeyEvent e) {
                        System.out.println("A key was pressed");
                        backgroundpanelKeyPressed(e);
                   public void keyReleased(java.awt.event.KeyEvent e) {
                        System.out.println("A key was released");
                        backgroundpanelKeyReleased(e);
    And then the code for my key events is as follows:
         // pressing the arrow button will allow the ship to move
         public void backgroundpanelKeyPressed(java.awt.event.KeyEvent e) {
         System.out.println ("In Here!");
         switch(e.getKeyCode()) {
         case KeyEvent.VK_LEFT:
         System.out.println("Left key pressed");
         break;
         case KeyEvent.VK_DOWN:
         System.out.println("Down key pressed");     
         break;
         case KeyEvent.VK_UP:
         System.out.println("Up key pressed");     
         break;
         case KeyEvent.VK_RIGHT:
         System.out.println("Right key pressed");     
         break;
                   // releasing the arrow button will stop the ship from moving
         public void backgroundpanelKeyReleased(java.awt.event.KeyEvent e) {
         switch(e.getKeyChar()) {
         case KeyEvent.VK_LEFT:
         System.out.println("Left key released");
         break;
         case KeyEvent.VK_DOWN:
         System.out.println("Down key released");
         break;
         case KeyEvent.VK_UP:
         System.out.println("Up key released");
         break;
         case KeyEvent.VK_RIGHT:
         System.out.println("Right key released");
         break;
    I can't find the problem with any of that, but something is intercepting my key events before they even get there. Pressing the arrow keys does nothing, but if I hit the spacebar, then it calls Background's constructor.
    I searched through the entire code, and nowhere is there any key listener, or any reference to the Background class aside from where I am actually trying to call it.

    Does your program always react when you press space? Because if it didn't I'd guess you have problems with the event focus (or whatever it's called). Let's say you add your KeyListener to the Frame/Applet your game is displayed in. At some stage during gameplay a java.awt.Button is pressed. The button will keep the focus and subsequent keypresses will be reported solely to it, so your KeyListener has to listen at the button, too (or you can do a requestFocus() for the component you want to listen to, whenever it looses focus. See FocusListener on this).

Maybe you are looking for

  • BBM is not working on my new q10

    Hello, i just bought new Q10 yesterday and since then i couldnt log into BBM, today i wiped data and factory reset the device and still i have the same error. it says Temporary Server Error. A temporary server error has occurred. Please try again Eal

  • Opening Fireworks files in Photoshop

    I created some drawings in Fireworks CS4 web standard, and sent them to a friend who has a CS4 that has photoshop instead of Fireworks, as he uses it for magazine editing and not for web publishing. The drawings went out in .png format with about 10

  • Acceptable Quicktime Formats in FCP

    Hi, I'm trying to encode an MP4 file for use in FCP, however each codec I use seems not to be readable in FCP. Which QT codecs will be recognizable? Thanks....

  • HOW TO CONVERT SAP DB TABLE TO XML FILE

    Initially I want to store sap db table as xml file so that an external program can read it. Also i want that when table is updated only updated data is stored in xml file. Edited by: Sandip Mane on Apr 2, 2008 9:19 PM Edited by: Alvaro Tejada Galindo

  • Error while connecting to DB Schema from WebLogic

    1.     I have installed DB 11.2.0.1, run RCU utility to create the schema, IDP_OIF, and Weblogic 10.3.3 on windows 2008 64bit version. Then i installed OIM 11.1.1.2 and then applied the patch 11.1.1.3. Post that, i configured Weblogic and created a n