Menu not activated from mnemonic

Hello All,
Please consider the following code.
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class Test extends JFrame{
    public Test()
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
    public static void main(String[] argv)
        new Test();
    private void jbInit() throws Exception {
//      new MyKeyboardFocusManager();
      JMenuBar menuBar = new JMenuBar();
      JMenu menu = new JMenu("File");
      JMenuItem menuItem = new JMenuItem("Test");
      menu.setMnemonic(70);
      menu.add(menuItem);
      menuBar.add(menu);
      this.setSize(200,100);
      this.setJMenuBar(menuBar);
      this.show();
    class MyKeyboardFocusManager extends DefaultKeyboardFocusManager
        public MyKeyboardFocusManager()
            KeyboardFocusManager.setCurrentKeyboardFocusManager(this);
        public boolean dispatchKeyEvent(KeyEvent event)
            Component component = event.getComponent();
            System.out.println("dispatchKeyEvent > component dispatching the KeyEvent : " + component.getClass().getName());
            return super.dispatchKeyEvent(event);
        public void processKeyEvent(Component component, KeyEvent event)
            System.out.println("processKeyEvent > component processing the KeyEvent : " +
                               component.getClass().getName());
            super.processKeyEvent(component,event);
}If you run the code a simple JFrame will appear with a menu. If you press <Alt-F> the File menu will open. Standard stuff.
Now uncomment the //new MyKeyboardFocusManager(); line and run the code again. The menu no longer activates on the <Alt-F> key event. What is going on????
The MyKeyboardFocusManager class simple prints out some text and forwards the event to the parent. Why should this stop the frame activating the menu????
To make things even more confusing. If you add a component to the JFrame and move the focus to the component, the <Alt-F> key event works and the menu is shown.
Any help appreciated as I am very confused.....
nes

Since you are using your own KeyboardFocusManager that is not handling events by calling super.<method()>. I think you should write your MyKeyboardFocusManager as given below:-
     class MyKeyboardFocusManager extends DefaultKeyboardFocusManager
          KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
          public MyKeyboardFocusManager()
               KeyboardFocusManager.setCurrentKeyboardFocusManager(this);
          public boolean dispatchKeyEvent(KeyEvent event)
               Component component = event.getComponent();
               System.out.println("dispatchKeyEvent > component dispatching the KeyEvent : " +
                    component.getClass().getName());
               return kfm.dispatchKeyEvent(event);
//               return super.dispatchKeyEvent(event);
          public void processKeyEvent(Component component,KeyEvent event)
               System.out.println("processKeyEvent > component processing the KeyEvent : " +
                    component.getClass().getName());
//               super.processKeyEvent(component,event);
               kfm.processKeyEvent(component,event);
     }

Similar Messages

  • Some pages of my website are not active from the home page

    Built my website with iweb.  When I go to the site the tabs to all the pages show, but several of them are not active from the home page.  If I go to one of the active pages I can then click on the other pages.  Is there a way to fix this?  I've tried reloading the entire site, but several of the tabs remain inactive from the home page.  Any help would be greatly appreciate - Thanks,  Jodi

    Thanks Roddy - I tried moving it down and it didn't work - That line is in the Template I used to build the site and is on every page.  I did finally get the command A to work, but there's nothing covering those bottom three tabs.
    However, when I put my mouse in the area of the box where it has my name (the image you sent me above) it shows a link desktop/site/booker_files and I noticed I have one of the rss feed blue arrows, but I can't seem to delete it.  I wonder if that has something to do with it.  It does the same thing on the website if you hover with your mouse. 
    Truly appreciate your help.
    Jodi

  • Links in pdf not active from Preview

    If I create a pdf from a Word .doc file, the links are not active in Preview but are active if I use Adobe Reader 10 (I prefer Preview as my default pdf reader).  However if I have Google download a document as a pdf file, that pdf file has active links in Preview - what's the difference and how can I get Preview to always have active links in a pdf file that is created by OSX?

    hello, the pdf viewer is still somewhat experimental and under very active development - you could try if the same error is occurring in the current development version, which you can download as an addon from http://mozilla.github.io/pdf.js/extensions/firefox/pdf.js.xpi
    in case it has the the same rendering problems, you could then file a bug report at https://github.com/mozilla/pdf.js/issues (a github account is necessary for it though) - please also provide a sample document where the error is apparent!

  • Windows 2012 Activation from Windows 2008 R2 KMS server

    Hello,
    We have 2 KMS servers in our Domain. One has server has KMS key for Windows 2012 KMS installed and other not.
    I have joined first windows 2012 server to domain and its been 3 hours the server is still not activated from KMS server.
    When client contacts KMS server for Windows 2012 licnese, if key is not installed on first KMS server, will it automatically contact second one? Do I need to change sonmething?
    One more question:
    Is it possible to have Windows 2012 key installed on the same KMS server, which is already acting as KMS sertver for Windows 2008R2? and Windows 2003 R2? or wil this cause any issues?
    Mahi

    Hello,
    Once a KMS host is activated, it will publish it's record to DNS.  KMS clients attempting to activate will query DNS to get a KMS host, if there is more than one, they will use the first one they get.  The DNS server should be rotating which records
    it hands out.
    If they activate, they will cache that record and attempt to use it when they renew, if they fail to renew or activate, they will query DNS for the KMS host again.
    Since this is a new KMS host it will need at least 5 KMS clients to contact it meet the count needs for Server.
    What version of Windows is the other KMS host machine is it Windows Server 2008, Windows Server 2008 R2 or is it Windows Server 2003 R2?
    Thanks, Darrell Gorter [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights.

  • Transaction is not active

              Hi,
              We have a stateless bean defined with 'Bean' transaction type. We open a transaction
              in this bean and then call a stateful bean located on a different application
              server (container). This stateful bean is defined with 'Container' transaction
              type with trans attribute 'not supported'.
              We also tried to define the stateful bean with a transaction type 'Bean' and trans
              attribute 'not supported' and still received the same error as written below:
              We receive an error in the stateless bean 'transaction is not active' from the
              stateful bean. This error only happends after the 3rd call to the stateful bean.
              The stateful bean does not open any transaction.
              

    There is some further discussion about using 'Not Supported' in the
              newsgroup
              that you might find helpful (bascially, it is implementor defined).
              WLS does not start any transaction in the case of 'Not Supported'.
              If a transaction already exists, it is suspended.
              If you call another EJB that requires a transaction, you will
              get an error that indicates that a transaction is not active.
              "Tamar" <[email protected]> wrote in message
              news:3ec7a215$[email protected]..
              >
              > Hi,
              >
              > We have a stateless bean defined with 'Bean' transaction type. We open a
              transaction
              > in this bean and then call a stateful bean located on a different
              application
              > server (container). This stateful bean is defined with 'Container'
              transaction
              > type with trans attribute 'not supported'.
              > We also tried to define the stateful bean with a transaction type 'Bean'
              and trans
              > attribute 'not supported' and still received the same error as written
              below:
              > We receive an error in the stateless bean 'transaction is not active' from
              the
              > stateful bean. This error only happends after the 3rd call to the stateful
              bean.
              > The stateful bean does not open any transaction.
              

  • HT1414 hi, my "restore from backup" menu is not active how can i get it on?.

    hi, my "restore from backup" menu is not active how can i get it on?.

    Hello imefromakwaibom
    Check to make sure that you have a back up by going to the iTunes Preferences and click on the Devices Tab to see a list of backups. If you have your Side Bar showing you can right click on the iPhone and should have the option to restore from back up.
    iOS: How to back up and restore your content
    http://support.apple.com/kb/HT1766
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

  • I get "an error has occured" when trying to download from the AppStore.  I can not re-download as the button is not active.

    I encountered the response "an error has occured" when I downloaded Maverick X from the App Store.  I can not try to re-download as the download button is not active.  I have tried rebooting and to get the download from apple.com but it keeps redirecting to the App Store.
    Suggestions?

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message (command-V).
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some private information, such as your name, may appear in the log. Anonymize before posting.

  • Mac Pro will not restart from dropdown menu

    Hi all,
    My Mac Pro will not restart from the dropdown menu or when clicking the 'restart computer' when installing software updates. I have an external firewire hard drive hooked up as part of my backup process. It contains a clone of my startup disk.
    I have tried disconnecting the firewire drive, rebooting then attempting to restart from the dropdown menu. Still no joy. I always have to end up shutting down manually by holding the power button in and then restarting with the power button.
    Any thoughts?
    Thanks in advance.
    Dennis

    You might try Safe Mode (It will take more time to startup in Safe Mode because it runs a directory check.)
    If your Shutdown functions correctly that way, go to System Preferences >> Accounts >> Login Items, and remove them. Boot normally and test. If not go to ~(yourHome)/Library/Contextual Menu Items and move whatever is there to the desktop. Then do the same with /Library/Contextual Menu Items. Lastly, try moving ~(yourHome)/Library/Fonts to your desktop and restarting.
    Log out/in or restart, if that sorts it start putting items back one at a time until you find the culprit.
    EDIT: Also, if you can launch Activity Monitor in your Utilities folder and see if you can find the process that is still running.
    -mj
    Message was edited by: macjack

  • Anyone any advice on how to stop my mail "activity" from continuously caching? is this a problem? I have had inbox issues recently that are not resolved yet but I am not sure if they are related.

    Anyone any advice on how to stop my mail "activity" from continuously caching? is this a problem? I have had inbox issues recently that are not resolved yet but I am not sure if they are related.

    Quit Mail. Force quit if necessary.
    Back up all data. That means you know you can restore the Mail database, no matter what happens.
    Triple-click the line below on this page to select it:
    ~/Library/Mail/V2/MailData/Envelope Index
    Copy the selected text to the Clipboard (command-C). In the Finder, select
    Go ▹ Go to Folder
    from the menu bar. Paste into the box that opens (command-V), then press return.
    A Finder window will open with a file selected. Move the selected file to the Desktop, leaving the window open. Other files in the folder may have names that begin with "Envelope Index". Move those files, if any, to the Trash.
    Log out and log back in. Relaunch Mail. It should prompt you to re-import your messages. You may get a warning that the index is corrupt and that Mail has to quit. Click OK.
    Test. If Mail now works as expected, you can delete the file you moved to the Desktop. Otherwise, post your results.

  • When I try to print from web page I get "printer not activated - error code 30", but I can copy text into Word document & printer works.

    I am unable to print anything from an internet web page. I continually get "printer not activated, error code- 30" followed by "An unknown error occurred while printing". I can copy the material from the web page, place into a Word document and then print. This just started yesterday and I have no idea why. Would appreciate your advice!

    See this:
    [http://kb.mozillazine.org/Problems_printing_web_pages#Prints_to_a_small_portion_of_the_page]

  • When I try to print from web page I get "printer not activated - error code 30", printer works on Internet Explorer

    When I try to print from web page I get a dialogue box "Printer not activated - error code 30" followed by a dialogue box "An unknown error occurred while printing". The printer works on websites when I use Internet Explorer. Also, if I copy the web page and paste it into a Word document, I can print a copy. This issue just started this week; I have not encountered this problem prior to this week. Please advise.

    What does that error message say?
    See this: http://kb.mozillazine.org/Problems_printing_web_pages

  • How do I revert to abackup from time machine? The backups prior to Lyon install are not available  - restore button is not active. I wish to return to Snow Leopard.

    How Do I revert to Snow Leopard from Lyon?
    The backups prior to Lyon install are not available... the restore button is not active.
    thanks!

    You need to do a full system restore from your last Snow Leopard backup.
    See #14 in  Time Machine - Frequently Asked Questions.

  • I am trying to install Illustrator C6 on new system (Win8.1), Already de-activated from old system.  I downloaded the 3 files.  First file opened and had fonts, but second file (1.8Gb) does not open; does not appear to have an exe file. How do i install?

    I am trying to install Illustrator C6 on new system (Win8.1), Already de-activated from old system.  I downloaded the 3 files.  First file opened and had fonts, but second file (1.8Gb) does not open; does not appear to have an exe file. How do i install?

    what files (names and extensions) did you download?
    Downloadable installation files available:
    Suites and Programs:  CC 2014 | CC | CS6 | CS5.5 | CS5 | CS4, CS4 Web Standard | CS3
    Acrobat:  XI, X | 9,8 | 9 standard
    Premiere Elements:  13 |12 | 11, 10 | 9, 8, 7
    Photoshop Elements:  13 |12 | 11, 10 | 9,8,7
    Lightroom:  5.7.1| 5 | 4 | 3
    Captivate:  8 | 7 | 6 | 5
    Contribute:  CS5 | CS4, CS3
    Download and installation help for Adobe links
    Download and installation help for Prodesigntools links are listed on most linked pages.  They are critical; especially steps 1, 2 and 3.  If you click a link that does not have those steps listed, open a second window using the Lightroom 3 link to see those 'Important Instructions'.
    window using the Lightroom 3 link to see those 'Important Instructions'.

  • I updated my iphone 3gs to ios 5.0.1 from ios 4 , now its saying that sim is not activated but the sim is still inside

    i updated my iphone 3gs to ios 5.0.1 from ios 4 , now its saying that sim is not activated but the sim is still inside
    PLSS HELP ME OUT !!!!

    Sounds like your phone was hacked to work with any network. Doing the update re-locked it to the original carrier. All you can do now is contact the carrier it is locked to to see if they have an unlocking policy. Note that if it's AT&T they do not offer unlocking. otherwise find an un-activated sim for the original carrier and you can use it as an iPod.

  • Itunes will not open from desktop icon or start menu?

    itunes will not open from the desktop icon or from the start menu?

    Are you getting an error message when you try to launch iTunes, patrice? If so, what does it say? (Precise text, please.)

Maybe you are looking for