Accelerator / Shortcut

How do I add an accelerator key (or shortcut) to a button on a Java Dialog (swing)? I haven't seen an example of this and it seems like it shouldn't be that tough... Any ideas?

http://java.sun.com/j2se/1.3/docs/api/java/awt/event/KeyEvent.html
youll notice KeyEvent inherits isAltDown() from input event
you can have your class implement KeyListener and then override
public void keyPressed(KeyEvent e) {
if( e.isAltDown() == true ){
do();
public void keyTyped(KeyEvent e) {}
public void keyReleased(KeyEvent e) {}
or add a KeyStroke action:
KeyStroke ent = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
Action entAction = new AbstractAction()
public void actionPerformed(ActionEvent e)
if(  ){
do();
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ent, "ENTER");
getRootPane().getActionMap().put("ENTER", entAction);

Similar Messages

  • CVS keyboard accelerators lost after restart

    Hi
    I set up accelerator keys for CVS edit (F10) and CVS commit (F11). Whilst JDeveloper is running, these keys work fine and I am able to edit and commit with these shortcut keys.
    However, when I restart JDeveloper, the settings are lost and I have to set the keys again - (I have to do this each time I restart JDeveloper).
    When I set keys F10 and F11 to other accelerator shortcuts such as make selected or run selected these work fine, even after restarting JDeveloper. The problem only seems to be with the CVS commands.
    Do I have to some additional configuration for the CVS accelerators?
    I am using JDeveloper 9.0.3.1 and the problem occurs on both Windows XP and SUSE Linux 8.1.
    Thanks
    Usman

    I'm seeing this problem with set accelerators being lost after restart with JDeveloper Preview 10.1.3.0.2.
    I set an accelerator to an external tool (Tomcat Startup and Tomcat Shutdown) and the accelerator is gone after I restart JDeveloper.
    I apologize if this is a known bug in Preview... I did a cursory search through the forums and only found this one.
    Thanks,
    Chris

  • Disable CTRL + R on windows

    How can I completely disable CTRL+R (call) Skype's keyboard shortcut on Windows 8.1?
    (it is very annoying - working in webdevelopment and using the same keyboard shortcut to reload the browser)
    Already done:
    Settings -> Keyboard shortcut turn off

    These shortcuts are not defined in Skype's keyboard shortcut, but are in-build accelerator shortcuts; at least in the latest Skype versions. As far as I can see, they have already been available in Skype 6.9 but are not present in 6.6. 

  • How to make the shortcut (accelerator) a ContextMenu to be global?

    how to make the shortcut (accelerator) a ContextMenu to be global to the Stage?

    OK, I'm going the applescript route. When I run the script within automator, it works fine. However, when I run the script from a menu as a service, it has no effect at all on iTunes. I must be missing something.
    Here's my script:
    tell application "iTunes"
              if player state is stopped then return
              try
                        set player position to (get player position) + (-5)
              end try
    end tell

  • Shortcut (accelerator key) on radiobutton or other control ?

    Hi all
    How to implement accelerator keyboard shortcuts on a radiobutton groups in a dialog ?
    The keyboard shortcuts are shown with an underlined char on each label of the radiobutton group.
    Windows wordpad.exe use this method in the 'Search & Replace' dialog ?
    Is it possible to use this with a checkbox controls ?
    Thanks in advance from a newbee

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • Accelerator (keyboard shortcut) for Buttons?

    Hi all,
    Is there some way to add an Accelerator (like the one available for Menu controls) or something similar to a Button? I would like to make it possible for the user to press Ctrl+S and save her current work, or Ctrl+Z to undo etc.

    jsmith wrote:
    On Windows you need to hold down the Alt key to get the Mnemonic to arm (underlines the Mnemonic key, e.g. the P in _Print), then press the mneomnic key, so Alt+P activated your button for me.I know, but I still couldn't get it to work (and I like Ctrl better :) ) so I went with the EventFilter:
            rootBorderPane.addEventFilter(KeyEvent.ANY, new javafx.event.EventHandler<KeyEvent>() {
                @Override
                public void handle(KeyEvent ke) {
                    if(ke.getCode()==KeyCode.S && ke.isShortcutDown())
                        //TODO Save
                    else if(ke.getCode()==KeyCode.W && ke.isShortcutDown())
                        printPreviewMisljenjePsihologa();
                    else if(ke.getCode()==KeyCode.P && ke.isShortcutDown())
                        printMisljenjePsihologa();
                    else if(ke.getCode()==KeyCode.Z && ke.isShortcutDown())
                        //TODO Undo
                    else if(ke.getCode()==KeyCode.Z && ke.isShiftDown() && ke.isShortcutDown())
                        //TODO Redo
            });Performance? Who cares about performance... 8-)

  • When I clickon Mozilla from desktop shortcut or from start menu, i get "search by speedbit which apparently came with a DAP accelerator recent donload, how do i get it back to mozilla firefox start page?

    I downloaded "Intelligent Updater" utilizing a DAP accelerator and there was a speedbit video accelerator in the package. There were no selections other than to download or not so I had no idea that this would result. When I click on Mozilla icon I get a speedbit browser for 1st page., I CAN type in mozilla and get homepage thatway or use most visited. The top bar on screen shows "SEARCH BY SPEEDBIT- MOZILLA FIREFOX".

    See also:
    *Tools > Options > Privacy > History: "Remember search and form history"
    *https://support.mozilla.org/kb/Form+autocomplete
    The "Use custom settings for history" setting allows to see the current history and cookie settings, but selecting that setting doesn't make any changes to history and cookie settings.<br />
    Firefox shows the "Use custom settings for history" setting as an indication that at least one of the history and cookie settings is not the default to make you aware that changes were made.<br />
    If all History settings are default then the custom settings are hidden and you see "Firefox will: (Never) Remember History".<br />

  • Shortcut Key in JInternalFrame

    Hi,
    I have an application that has multiple JInternalFrames displayed within split panes. I am trying to set shortcut keys to cycle through the visible JInternalFrame. I have a Menu Item oCycleWindows, on which I called setAccelerator() with Ctrl+Shift+M. In th emenu handler for this item, I have defined a function that checks the current focussed internal frame, and accordingly picks the next one to get the focus.
    My problem is as follows: on clicking Ctrl+Shift+M, I am able to see that the next window has focus (the title bar color changes), but when I use the up/down keys to navigate within the newly focussed window, actually the navigation happens in the previous window....
    I have a tree view at the left, and two views at the right, and going from the tree view to any of the right views sometimes works correctly, sometimes doesn't (in fact i believe this happens every alternate time I shift to the non-tree view). Here, I have tables in the right views, and I try to select different rows using up/down keys once the right view has the focus, but the navigation occurs in the Tree view, with previous/next node getting selected instead!
    The funniest part is, the problem isn't there if the shortcut defined is 'F6', but for any other shortcut (F12, F11, Ctrl+M, Ctrl+Shift+M, Ctrl+K, CTrl+Shift+K etc.) this problem is seen.
    Does anyone have ANY idea why this happens? I tried to look up the bugs DB, but couldn't find anything specific to this...
    Sample Code:
    JMenuItem oCycWin = new JMenuItem("Cycle Windows");
    oCycWin.setMnemonic('C');
    oCycWin.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK, true));
    //oCycWin.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0, true));
    oCycWin.addActionListener(new ActionListener()
       public void actionPerformed(ActionEvent e)
          /* oCurWin is a JInternalFrame object (extended class) that tracks the
             current focussed window
          if(oCurWin.ID == 1)
            oCurWin.ID = 2;
          else if(oCurWin.ID == 2)
            oCurWin.ID = 3;
          else
            oCurWin.ID = 1;
          oCurWin.setVisible(true);
          try
         oCurWin.setSelected(true);
          catch(java.beans.PropertyVetoException e)
         System.out.println("Can select oCurWin");
    });This code works fine for accelerator set as F6, and when we shift to the tree view. But sometimes on shifting focus to any of the right views, with accelerator not F6, although the right view appears to be focussed due to change in title bar color, the navigation continues in the tree view.
    Thanks...
    Shefali

    Hi,
    have you tried requesting the focus on your newly selected internal frame ?

  • After latest update shortcuts load with an error message

    i get an error message saying it cant find the address but it still loads,but i have to click on the error message to get rid of it.
    please help...and thanks in advance.

    If you get that error message if you click a shortcut on link in an external program to open Firefox then see:
    *http://kb.mozillazine.org/Windows_error_opening_Internet_shortcut_or_local_HTML_file_-_Firefox
    Otherwise you can check for issues caused by extensions.
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Why are the keyboard shortcuts for new window and new tab (N) and (W) instead of (W) and (T) when I right-click on bookmarks in my toolbar?

    If I right click on a link in a page, the context menu allows me to open a new tab if I hit t on my keyboard and a new window if I hit w. In the bookmarks menu, these shortcuts change to w and n respectively. Hitting t results in deletion of the bookmark. Can this be changed so it is consistent with the in-page context menu?

    You can middle-click a link to open the link in a new tab.
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • Menus on newest update have display issues. Click and they drop with no interior and/or constantly flash on and off. Main meun and shortcut menus both do this.

    The other day I was told Firefox had updated (I have auto update enabled). Since then I have observed that the menus (file, edit etc.) when clicked quickly drop and display and then disappear leaving only an outline of the menu. There is lots of flashing. This happens on the shortcut menus too.

    Installed FlashPlayer 9. All the pictures are almost lossless PNG.
    No hardware acceleration, bad quality YT. Check the edge of the stars, or the numbers bottom left and right.
    Hardware acceleration ON, smooth buttons, but with FP9, there is no title on pause top left, this is just 1 reason why I want to use FP10 or FP11, without GPU acceleration, but nice quality.
    As you can see, with FlashPlayer 9, only CPU is working, and the VGA driver is not crashing with 4! 720p youtube videos (all 4 playing in the same time). Still, with hardware acceleration, the quality is good, and smooth. All I want is an option to turn off gpu acceleration for Flash 11 just like they way Flash 9 was.

  • I cannot drag a url to the desktop to make a shortcut anymore.

    I cannot drag a url to the desktop to make a shortcut anymore. Not with the favicon, not the url, not from the bookmarks. Nothing

    Does if work if you keep the Ctrl key pressed while dragging the URL?
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode

  • Eclipse RCP and swing key accelerator

    Hi,
    I have a JTree inside a view and a popup message when you right click
    on the tree.
    I added a key accelerator to the menu and I see the shortcut on the menu but when I use the shortcut, nothing happens.
    I believe the problem is SWT -> SWING issue but I don't have any idea
    how to solve it.
    Thanks in advance
    Dekel

    Java 'WebStart is (in principle) a fine distribution/deployment/update technology.
    It covers smart versioning of jars/jvms.
    Native user experience and Swing poses no problem.
    I prefer Swing as one can construe one own controls in detail.
    Both Eclipse RCP and Netbeans Platform have a very specific starting point.
    Both come with a considerable amount of code.
    In fact have a feasability study in the form of writing hello-worlds in both.
    The unmentioned alternative, starting from scratch with Swing,
    may have some benefits.

  • All keyboard shortcuts are disabled, and I can't enable them - resetting firefox or safe mode not helping

    For example, Ctrl-T is grayed out / disabled so I can't open a new tab using the keyboard.
    Ditto for ALL other keyboard shortcuts - they're all disabled / grayed out.
    PS - I've used Firefox for years, this happened about a month or so ago, and it's been that way ever since, even after rebooting computer.

    '''Try Firefox Safe Mode''' to see if the problem goes away. [[Troubleshoot Firefox issues using Safe Mode|Firefox Safe Mode]] is a troubleshooting mode that turns off some settings, disables most add-ons (extensions and themes).
    If Firefox is open, you can restart in Firefox Safe Mode from the Help menu:
    *In Firefox 29.0 and above, click the menu button [[Image:New Fx Menu]], click Help [[Image:Help-29]] and select ''Restart with Add-ons Disabled''.
    *In previous Firefox versions, click on the Firefox button at the top left of the Firefox window and click on ''Help'' (or click on ''Help'' in the Menu bar, if you don't have a Firefox button) then click on ''Restart with Add-ons Disabled''.
    If Firefox is not running, you can start Firefox in Safe Mode as follows:
    * On Windows: Hold the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * On Mac: Hold the '''option''' key while starting Firefox.
    * On Linux: Quit Firefox, go to your Terminal and run ''firefox -safe-mode'' <br>(you may need to specify the Firefox installation path e.g. /usr/lib/firefox)
    When the Firefox Safe Mode window appears, select "Start in Safe Mode".<br>
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]] article to find the cause.
    ''To exit Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    When you figure out what's causing your issues, please let us know. It might help others with the same problem.

  • I am using Firefox 4.0 Beta 10. It doesn't start immediately after I click on the Firefox button located in my shortcut bar. And sometimes it even doesn't open. I don't know why it occurs, so please look into this matter. Thanks!

    Whenever I click on the button of Firefox 4.0 Beta 10 located in my shortcut bar. It opens after a very long time i.e. after 5-10 minutes after I get irritated and start using Safari. And sometimes it doesn't even open. Please look into this matter. :D
    Thanks

    Try disabling hardware acceleration in your Firefox settings and see if it helps:
    From the Firefox menu, go to '''Options''' and click the '''Advanced''' panel, then select the General tab. Clear the box in front of "Use hardware acceleration when available" so that it is unchecked, then restart Firefox. ([http://support.mozilla.com/media/uploads/gallery/images/2011-01-27-04-52-31-8c9d82.png screenshot]).
    Ref: <br>
    https://blog.mozilla.com/tglek/2010/12/21/rude-surprise-startup-overhead-of-windows-font-apis/

Maybe you are looking for

  • ITunes crash when syncing apps to iPhone 4s

    I recently had to restore my phone as new.  I was able to sync to iTunes from my PC with no problem.   However, when I try to sync ANY apps, iTunes crashes.  How can I stop this from happening???

  • Portal Server rendering issue

    Hi , I have a single channel container in my portal.I am using a struts portlet to display content inside this portlet.The struts application interacts with an EJB application which in turn has calls to web services & db. All this content is rendered

  • Using general hierarchy of sales information system

    Hi, The sales manager uses oftenly the general hierarchy in order to sort the information that could extract from sales information system. So, firstly he uses the tranasction MCK1 to create a hierarchy and after that he executes the transaction MCSI

  • Remoting Security: Best Practice

    I am exploring Remoting and I am curious about security best practice. By default, Enable-PSRemoting will configure an HTTP listener that listens to all addresses. Initially I thought this address was the addresses of the computer making the demoting

  • Error applying xMII 12 sp2

    Hi all, We have SAP xMII 12.0.0 and trying to apply the SP2 using SDM. Following error occurred during this process ... Reason: Application alias [XMIIVirtual] for application [sap.com/xappsxmiiear] already exists in the HTTP Provider Service. The ap