How to attach short cut keys to open a menu in a menubar

Hi,
I have three menus say File, Edit, Help in the MenuBar and i want to open these menus when i press short cut key from Key board, say Alt+F for File menu, Alt E for Edit menu and so on. When the file menu is shown i want to select the New menuItem in it by CtrlN.
When i press Alt key the letter F in File, E in Edit should be underlined.
So can you please give me some sample code for this.
Thanks.

Hi. Here is an example. It works on Windows. I am not sure about other platforms.
   import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.effect.DropShadow;
import javafx.scene.effect.Effect;
import javafx.scene.effect.Glow;
import javafx.scene.effect.SepiaTone;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.layout.*;
import javafx.scene.*;
import javafx.geometry.*;
import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.geometry.Pos;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.stage.Stage;
public class MenuSample extends Application {
  public static void main(String[] args) { launch(args); }
  @Override public void start(final Stage stage) {
    // create some menus.
    final Menu fileMenu = new Menu("_File");
    fileMenu.getItems().addAll(
      new MenuItem("_Open"),
      new MenuItem("_Save"),
      new SeparatorMenuItem(),
      new MenuItem("_Exit")
    final Menu playMenu = new Menu("_Play");
    playMenu.getItems().addAll(
      new MenuItem("_Start"),
      new MenuItem("_Stop"),
      new MenuItem("_Pause"),
      new CheckMenuItem("_Rewind")
    final Menu helpMenu = new Menu("_Help");
    helpMenu.getItems().add(
      new MenuItem("About")
    final MenuBar menuBar = new MenuBar();
    menuBar.getMenus().addAll(fileMenu, playMenu, helpMenu);
    final VBox layout = new VBox(10);
    layout.getChildren().addAll(menuBar);   
   // layout.setAlignment(Pos.CENTER);
    layout.setStyle("-fx-background-color: linear-gradient(to bottom, silver, derive(silver, 80%));");
    final Scene scene = new Scene(layout, 400, 525);
    stage.setScene(scene);
    stage.show();
  //  ObservableList<Node> menuNodes = ((HBox) menuBar.lookup("HBox")).getChildren();
   // Control menuNode = (Control) menuNodes.get(menuNodes.size() - 2);
   //  menuNode.setMaxWidth(Double.MAX_VALUE);
   // HBox.setHgrow(menuNode, Priority.ALWAYS);
}

Similar Messages

  • Short cut key for created menu

    Hello All:
        Want to know if it is possbie lt put a short cut key to a addon menu...
        I can't attach it in SBO because when it starts menu has not been generated yet, and it automatically loose it. I can't seem to capture combination keys in main main desktop using keysdown event type. Is there anything that I can use??
    Sincerely Yours

    Hello Bo,
    You may try the form key down event. sample code:
    SHIFT+P: open BP
    CTRLSHIFTQ: open sales quotation
    Public Sub ItemEventHandler(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, _
        ByRef BubbleEvent As Boolean) Handles oApp.ItemEvent
          If pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_KEY_DOWN And pVal.Before_Action = True Then
                MsgBox("Modifier: " + CInt(pVal.Modifiers).ToString() + " Char precessed" + pVal.CharPressed.ToString())
                If pVal.Modifiers = SAPbouiCOM.BoModifiersEnum.mt_SHIFT Then
                    'SHIFT+P : Open the Business Partner               
                    If pVal.CharPressed = 80 Then
                        oApp.ActivateMenuItem("2561")
                    End If
                ElseIf pVal.Modifiers = SAPbouiCOM.BoModifiersEnum.mt_CTRL + SAPbouiCOM.BoModifiersEnum.mt_SHIFT Then
                    'CTRL+SHIFT+Q: open sales quotation
                    If pVal.CharPressed = 17 Then
                        oApp.ActivateMenuItem("2049")
                    End If
                End If
            End If
    End Sub
    Regards, Yatsea

  • File names missing from thumbnails when short cut keys are used

    Across several Adobe products I use (Photoshop CS3 and CS6, Captivate 5 and 5.5) I don't see filenames under thumbnail images when I use short cut keys to open or save documents. This happens in Windows 7 and Windows XP.
    When I use the short cuts the file names don't appear in the document window - all I see is thumbnails with nothing under them.
    If I open or save through the menus I don't have this problem.
    It doesn't always happen, but occurs maybe 75% of the time. Sometime the file names will appear at first, but if I navigate to another location they disappear. This only happens in the thumbnail view in the window. Other views show the file name but as they don't show the thumbnail aren't as useful when working with images.
    Does anyone know what is causing this, and how I get the file names to appear?
    Thanks

    Here's a couple of screenshots of the problem (Photoshop CS4 and Captivate 5.5 running in Windows XP). I have the same problem with Photoshop CS3, and now CS6, running in Windows 7 on another computer. It's not so bad when you can see images, but when you're trying to find folders, or have PSDs that don't thumbnail, then it becomes a nightmare trying to open or save anything.
    Thanks,
    Alistar

  • Short Cut Key for Personalized menu

    Hi
    I've created an Menu for the zoom function using personalization, Is it possible to setup a short key for the menu created
    Example: for the File menu we can use Alt+F similarly is it possible to build the short cut key for the custom menu created using personalization
    Please advice
    thanks
    Regards
    Ramesh Kumar S

    The Character '&' worked very well as expected...
    Thanks a lot
    Regards
    Ramesh Kumar S

  • How to set the short cut key for buttons

    Hi
    I dont know how to set the short cut keys for the button...can u pls help me out

    Do you mean a short cut key for buttons at client side (web browser)? If yes, you could do it with JavaScript~~~ ^o^

  • Unable to open a New Tab (including using the short cut key)

    I can't click for a new tab. short cut key also not working. I tried to uninstall and install it again, but it is still not working. How to solve this problem?

    Thank you so much for your help, greatly appreciated.

  • How to use short cut in MacBook Pro

    How to use short cut in MacBook Pro
    I cannot set short cut key on action, please advise method,
    Thanks!!

    Details please.
    And screenshots can be so useful to clarify a question (one can use the camera-icon to attach images).
    Anyway, you don’t get the option to select a Function Key in the Action Options or is the key not displayed in the Actions Panel after setting one?

  • Short cut key

    Hello,
             I'm facing a problem in assigning short cut key ( which is not defined in the button property list)  to the command buttons. 
             Please find the attached snapshot of my front panel vi. where in I have placed seven buttons next to each other. 
    My requirement : 
    1.    In run-time i need to move focus from one button to another from right to left as well as left to right using keyboard navigation keys. How can I do it?
    2.    Command should be executed only if the button is pressed twice. i.e once the button is pressed it has to ask for confirmation. Is there a possibility to do it? 
    Thanking you,
    Mr Sushmith
    Thanking you,
    Sushmith
    Solved!
    Go to Solution.
    Attachments:
    button.png ‏3 KB

    Hello,
    Can u please explain me how can I use event structure?? Or is there any other alternative?
    Thank you,
    sushmith
    GerdW wrote:
    Hi sushmith,
    1) Use an event structure to capture navigation keys and to set key focus (by PropertyNode!) accordingly...
    2) Use an event structure to capture the ValueChange event for those buttons. Show an additional dialog to confirm operation...
    GerdW wrote:
    Hi sushmith,
    1) Use an event structure to capture navigation keys and to set key focus (by PropertyNode!) accordingly...
    2) Use an event structure to capture the ValueChange event for those buttons. Show an additional dialog to confirm operation...
    Thanking you,
    Sushmith

  • Short cut key!!!help

    I have a menu like File --> Open, Exit. I want to set the Exit menuitem to have a short cut key like 'ctrl-x'. How can I do that?? I'm using JMenu as the menu bar. Thank you.

    a simple exemple :
    you must add it after you defined your component (jMenu or smthingelse)
    print() is the function that is called
    you can do the same with CTRl+X
    (use with Swing)
    /** Gestion de CTRL+P (print) dans la JFrame */
              _myFrame.registerKeyboardAction(
              new ActionListener() {
                   public void actionPerformed(ActionEvent ae) {
                        try {
                        print();
                        } catch (Exception ee) {
              "Print",
              KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P,java.awt.Event.CTRL_MASK, false),
              JComponent.WHEN_FOCUSED
    hope it helps

  • Cc2014 premiere short cut key not function in Window 7?

    Hello All
    Just got my premiere CC 2014 update recently somehow all the Hotkey or short cut key is not function like "space bar C or V )
    the keyboard works fine "i can type"wonder if anyone have the same problem or know how to solve this problem
    thank you   
    Kelvin
    and I test with other adobe product photoshop bridge works fine, in the premiere interface i go under edit/ keyborad shortcuts on the selection tool razor tools slip tool etc none of them had the shortcut mark on the side
    I try to click and create a shortcut to it but unable to, what is going on I had a few project due very soon. please help

    I'm the only person that needs to save the Titles?
    I do it sometimes when I want to reuse a title in more than one project.
    When you export out the Titles, what happens then?
    Only then does it become a separate file, suitable for importing into other projects.  This is NOT necessary to export your finished video,  it's only necessary if you want to reuse the title in other projects.
    The Titles are photos and scrolling words, that are used together as a memoriam in different projects. So having the Titles as separate files on the HD is pretty much essential.
    That's more than just a title, which in PP usually contains only text.  For something this complex, it might be better to create a base project or template that contains all the elements you want to reuse, and then start new projects with that, renaming to a new project name immediately after opening the template.
    For example, I have an HD Wedding project that contains all my sequences, graphics and titles ready to go in organized bins.  I start by opening that project and do a Save As... using the couple's last name.  That way each new project starts with the elements I need and I don't have to recreate them all the time.

  • Locking out the startup short cut keys

    Anyone know how to get the Intel Macs to not allow the apple-s, apple-v short cut keys on startup? I have a loaner iMac from Apple and noticed that the Open Firmware Password application only keeps the user from switching the startup disk using either the apple-c or option key on startup. Unlike the PPC versions though, it does not stop the other short cut keys.
    So, anyone know how to lock down an Intel Mac like you could with the PPC ones?

    Hi...
    Thanks for reply..
    Can u give me some detailed information.. i.e. what i have to do exactly in the c/c++ code if i will use JNI?
    If possible give me the source code for that..

  • Short cut key definitions and symbols I cannot find on keyboard.

    Short cut key definitions, In the window drop down menu there is a short cut symbol for the EQ and others that I simply don't understand or see on my keyboard. My question is this, how do I make this shortcut work? The symbol in front of the command symbol.

    The option+command+E is represented as the ⌥⌘E symbolism, and by pressing those keys, will show the Equalizer.
    Reference the OS X keyboard shortcut guide for additional symbol information. Apple has placed the ⌘ symbol on the command key for a long time, but does not do this with other symbols for shift, control, option, and caps lock.

  • To set the short cut key for the menu when using CommandDesign pattern

    Hi All
    I have a menu File which has two menu items Load and save.
    Here for implementing the actionperformed iam using the command design pattern.
    Now iam not able to set the short cut key for the menu item......
    Please help me..............
    Thanks
    Arch

    The Java Tutorials: [How to Use Menus|http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html]
    db

  • Aperture Desk top short cut key - Disable ?

    Hi could some-one tell me how to disable a short cut key.
    I've gone to
    Aperture
    customise
    selected my custom command
    found the preset - with the associated Short cut Key.   I want to keep the Pre-set, but REMOVE the associated short cut key.
    Thanks for your help.
    Tony

    Go to "Aperture➞Commands➞Customize ... " and in the "Command List" section (lower left) select the command with the key binding you wish you remove, and press the "delete" key on your keyboard.  Then click "Save".

  • Assign text to short cut keys

    Is it posable to assign a web address or an e-mail address or even a text string to a particular short cut key combination?

    No. What you need is a Macro program. I use iKeys, but it is having issues with Leopard. There is QuickKeys and Keyquencer as well, but not sure how they are doing with Leopard as well. Leopard changed too many things around, and apps like these find it difficult to keep up with them.

Maybe you are looking for

  • Burning directly to DVD from FCPX fails ...

    When I try and burn from Final Cut Pro X there is no share monitor and it just processes and then does nothing.

  • HT2494 connecting macbook pro to projector

    I am having trouble getting the right output to a projector connected to my macbook pro using the thunderbolt to hdmi connector. It won't display the MS windows desktop I have running in vmWare. It also does not show the correct desktop when I move b

  • Need User Exists

    Hello Friends, i need User Exists for PR,PO,MIGO,MIRO Creation transactions , i need to save data in one Custom table for all these transactions. so that i can details for purchase life cycle from refering the single table . i donot require to refer

  • Deski report using sdk....?????

    Hi experts,     Is there a way to create a deski report  from a universe using sdk.... If so, please provide me some sample code... Regards, ksvsivam

  • If I update my Apple iPhone software, will it delete my music and videos?

    I need to update my software on my iPhone to iOS 5.1.1, but I am worried that it will delete all of my TV shows. Is that the case? Thanks.