Alt key causes NullPointerException

I am getting a NullPointerException in a Swing based GUI application when I use the 'Alt' key with JButtons containings mnemonics.
There was an earlier topic of the same issue traced to either setLookAndFeel() or using a Frame instead of JFrame. I am using a JFrame and not using setLookAndFeel() is not under consideration.
Anybody have any ideas?

Mine too! I'm not using setLookAndFeel(0 and am using JFrame! Here's my codeimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame {
  public Test() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = getContentPane();
    JButton jb = new JButton("Hello, McFly!");
    jb.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
        if ((ae.getModifiers()&ae.ALT_MASK)!=0) throw new NullPointerException();
    jb.setMnemonic('b');
    content.add(jb, BorderLayout.SOUTH);
    setSize(300, 275);
    setVisible(true);
  public static void main(String args[]) { new Test(); }
}Any ideas?

Similar Messages

  • Lasso tool problem, using alt key, no click within 5sec causes loss of active window focus

    I have been using Photoshop since ver. 4 and have never seen this happen.  The only difference is now I'm on Windows 7 64bit.  Did not have this problem with XP.  Current version CS3 Extended.
    Problem: While using Lasso tool with the alt key if I do not make a mouse click in 5 seconds Photoshop's active window loses focus for a split second and then the first point of my selection and the last point will connect.  Thus, wasting my time and my attempt at a selection.
    I have task bar buttons to "Never combine".  I see for that split second what appears to be another program button opening but it is so fast that I cannot see if there is a name on the task bar button.  The current Photoshop button moves to the right and back too fast.  This all happens very quickly as the window loses focus.
    I first thought it was some another program but after many searches found nothing I can identify as the cause.
    Right before posting this I had a thought and did a test that concluded in the 5 sec rule. For over a minute I held down the alt key and made a mouse click within the 5 second window of time and there was no loss of window focus.  While still holding down the alt key in this same test but not making a mouse click within 5 seconds the window lost focus and the tool stopped with my selection.
    I have a wireless Logitech M305 mouse that this morning updated the driver to its current version 5.20.51, Control Center version: 6.20.50.
    I have not tested a wired mouse, yet.
    Any help would be appreciated.  Anyone else seen this?  Windows 7 64 bit the culprit?????
    Message was edited by: golfnut333

    UPDATE
    After I removed Photoshop from Norton 360's Administrative Settings_Silent Mode Settings_User-Specified Programs, I did not have the problem with the lasso tool that I first had with loss of window focus.  I then put Photoshop back in the 360's settings and the lasso tool still worked, BUT...............
    After a couple of days of not using Photoshop and turning computer on and off in that time, I tried Photoshop again and the same problem, it came back.  Loss of focus after 5 seconds of not clicking mouse.  So, once again I open Norton and took Photoshop out of the User-Specified Programs and the problem went away, no loss of focus.
    So, I will see if after a couple of days of turning on and off the computer and NOT putting Photoshop in the Norton's User-Specified Programs setting if the problem stays fixed.
    I don't have to have Photoshop in the Norton's setting I just thought that it would be a good idea so Norton didn't try to do any background processes or whatever while I was working in Photoshop or I was rendering a filter or something.
    Another thought I also have the Full Screen Detection setting ON.  I do use Photoshop in Full Screen mode so maybe when having both the Full Screen mode and User-Specified Programs setting selected it makes something go wacky.
    Hope this helps anyone having the same problem I "did".  Will post back after a few days to let you know if focus problem is gone.
    If it does relieve the problem then I will leave Photoshop off the list in Norton.  No sense in trying to fix something that really doesn't matter, really.
    UPDATE 2
    January 8, 2011, I tried the lasso tool again and it still appears to be working. I did my standard test of holding the alt key and clicking to make selections then not click for 5 seconds or more and I did not lose window focus.  I do not know why the Norton 360 setting triggers the loss of focus but since I turned that setting off I'm not having any problem.
    Will update again if something changes.
    Anyone else out there with the same problem that was solved using this method?
    Message was edited by: golfnut333

  • A desperate cry for help; My alt key has rendered my mac useless!

    Hi!
    A few weeks ago I spilled a little glass of water on my macbook pro (2010/15") and as a consequence of this the alt key became dysfunctional. Although not mechanically jammed, the macbook seems to be registering a constantly activated alt key. This obviously renders the whole keyboard useless as every button I press results in: •Ω醵üıœπ˙ß∂ƒ¸˛√ªfiö÷≈ç‹›‘’‚ and various secondary functions.
    These are solutions i have tried:
    Resetting the PRAM and SMC
    Disabling the alt the key in system preferences
    Removing the alt keys and cleaning the switches
    Plain ol' baning away at the keyboard in sheer frustation
    I figured that the only solution would be getting the macbook pro repaired, but this is pretty costly here in Denmark; 3000 Dkk = 550 usd = 330 gbp. I never really got around to doing this and have been using a seperate keyboard ever since.
    But get this! In the small hours of chirstmas eve/day, I blow out all the christmas candles and go to turn of my macbook pro... there must have been some christmas magic in the air because the "f*•Ω∂é" thing just suddenly worked!!! ;D
    But alas, after a single restart im back to square one!
    Although extremely frustrated, I'm also a little hopeful that there might be a solution which doesnt involve replacing a whole component just because of one single key... ( I swear I sometimes hear that alt key laughing at me! ;p)
    Any advice, suggestions or thoughts would be greatly aprreciated
    Merry Christmas/Happy holidays and a happy New Year!
    Thanks in adavance

    Yea I know, this solution seems unevitable............ But im trying to avoid it
    I dont understand how a simple restart reversed the whole thing, i didnt even move the macbook.......?
    But then again I don't know what made it work in the first place..
    I was afraid that the water caused a short-circuit and that the alt key contact was somehow fried. But the fact that it worked again + the fact that a restart reversed this, might mean this is a software issue or at least an issue that can be resolved by some DIY, ................................or what?

  • No alt key access to top menus in full screen mode Ps CS5 Ext?

    I'm using the trial version of CS5 on a Win7 machine, after using Ps CS3 for a fair amount of time.  When painting in Ps, I am almost always in full screen mode.  In CS3, you could be in full screen mode and hit the alt key plus the active letter of a top bar menu, like F for File or T for Filter or W for Window, and that menu would appear, and you could hit subsequent active letters to get the associated function.  I used alt+I then E then H to flip the canvas horizontally.  Super quick and awesome!  Now the E has been changed to a G, but no matter.  The big deal is that in full screen mode, this no longer works!  I just get an error sound when I hit the alt and I button together. I have to hit Tab to bring up the menus and palettes before I can use the alt + top menu letter functionality.
    Is this an oversight, or is there functionality to disabling this hotkey use when in full screen mode?
    Any ideas?  Should I put this in the feature request forum?
    Thanks!
    db

    Hmmmm....
    When NOT in full screen mode, people on this forum sometimes complain that the Alt modifier key is activating the menus and causing subsequent operations for which they're using Alt (e.g., zoom out) to irritatingly trigger the Windows "ding" sound.
    Notably when IN full screen mode that's not happening with CS5 because the Alt key simply doesn't activate the menus.
    Interesting thought...
    Perhaps Adobe made it work this way on purpose so that they could tell people complaining about the first issue to run Photoshop in Full Screen mode.  That's just a guess.
    As a workaround to your issue, you could of course expand the Photoshop window to be very close to the full size of the screen and just keep running it as a Window, rather than using full screen mode at all.  Yes, I realize this isn't a fix, but just a possible workaround until such time (if ever) Adobe gets around to fixing the modifier keys to work properly (again).  I have chosen to use Photoshop this way myself, and other than wasting a bit of screen space it seems to be a pretty decent workaround to using F mode.
    Funny thing is it seemed Adobe had the modifier keys working pretty much properly in Photoshop CS4.  I wonder why they changed it.
    -Noel

  • Why doesn't my alt key work?

    In my Photoshop CC, the alt key only duplicates the layer; I can’t use the clone tool or the healing brush.  Does anyone know what is going on here?

    Or Diane might be trying to use the Spot Healing brush and Clone tools on empty layers without Sample all layers checked.  Or working outside an active selection.  I expect there are conditions that would cause such behaviour.
    Diane, if you are convinced everything is set right, and there is no user error (we all do user error now and again) then you might need to reset the tool from the Preset panel or Options bar.  Or if that doesn't help, it might be time to reset Preferences  (hold down Shift Ctrl Alt - Shift Cmd Opt while starting Photoshop.)

  • Problem getting (ALT key) to work in Flash

    Hi All,
    I hope there is somebody who can help me with the following issue:
    I can not get ALT key to work in Flash, if I want to use it in combination with other keys nor I can use it alone.
    For example, I have created an application which requires the usage of (ALT+F) in order to access certain thing, This does not seem to fire the key event.
    however if i use the same thing with (CTRL+F) or (SHIFT+F), it works fine.
    It is only ALT  which causes the key event not to fire.
    Is there a bug in Flash for using ALT key? Can anyone help me please?

    see here:
    http://forums.adobe.com/message/2127570

  • Seems like my Control or Alt keys are "on" after browsing with Firefox and I have to control-click or alt-click on the desktop to set things back to normal

    After a browsing session using Firefox, my system behaves like either the Contol key or Alt key is stuck "on". For example if I start clicking icons on my desktop, each one is highlighted and "added" as if I were holding down the control key while clicking on each one (thus selecting all the icons). If I physically press the control key and click, then click again without the control key down, the system then behaves as normal.

    Use "Firefox/File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit") to close Firefox if you are currently doing that by clicking the close X on the title bar.
    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
    *https://support.mozilla.org/kb/Troubleshooting+plugins

  • Left shift key remapped into alt key

    Hi Everybody
    The left shift key of my Macbook air started to work exactly like the alt key, like it was remapped.
    (the alt key works normally)
    The solution of the problem might be simple but I couldn't find any way to change the behaviour in Maverick.
    Can anyone help?
    Thanks
    and14

    Try a restart.
    Do a backup, using either Time Machine or a cloning program, to ensure files/data can be recovered. Two backups are better than one.
    Try setting up another admin user account to see if the same problem continues. If Back-to-My Mac is selected in System Preferences, the Guest account will not work. The intent is to see if it is specific to one account or a system wide problem. This account can be deleted later.
    Isolating an issue by using another user account
    If the problem is still there, try booting into the Safe Mode using your normal account.  Disconnect all peripherals except those needed for the test. Shut down the computer and then power it back up after waiting 10 seconds. Immediately after hearing the startup chime, hold down the shift key and continue to hold it until the gray Apple icon and a progress bar appear. The boot up is significantly slower than normal. This will reset some caches, forces a directory check, and disables all startup and login items, among other things. When you reboot normally, the initial reboot may be slower than normal. If the system operates normally, there may be 3rd party applications which are causing a problem. Try deleting/disabling the third party applications after a restart by using the application un-installer. For each disable/delete, you will need to restart if you don't do them all at once.
    Safe Mode
    Safe Mode - About
    Do you have another keyboard you could test with?

  • Cannot click bookmarks on menu bar after ALT-key when menu bar is hidden

    If you personalize the toolbars, dock the "Bookmarks objects" to the menu bar (useful to reduce space) and hide the menu bar (making it visible by pressing the ALT key) you're not able to click a bookmarks bar's item anymore because (after having shown it by pressing ALT key) as you click the bookmark button the menu bar loses focus causing the whole bar to be hidden again and the click event to be catched by the main window instead of the bookmark button.
    [http://alextm.no-ip.com/bookmarks_on_menubar.JPG Screenshot of the header with bookmarks]

    With F10 you obtain the same result, the menu bar is shown but when you click on a non-menu item the bar is hidden again not allowing the bookmark item to catch the click event.
    Of course I know how to move the bookmarks bar back to the tab bar, but it is not a solution to the problem I've posted, just a workaround. As I've said in my previous post I've moved the bookmarks bar there to limit the height of the window's heading section: if I move it down again I miss my target.
    Anyway, I don't think we are here to decide wherever to place the bookmarks bar, but to notify to the developers the presence of this issue.

  • Alt key frustration

    I keep working on a document, having to zoom in and out as well as change brush sizes and hardness, almost everything that involves the alt key, and it keeps getting me stuck on the menu bar.  This will either reset my tool to the previous one I was working with, cause me to button mash the alt key until something works again, or click on the image and undo whatever happened so that I can use what my desired feature is.
    Is there some way that I can take away the ALT key functionality to select any menu items so that I don't have to go through this, or is it simply a Windows 7 thing?  Cause this is annoying as hell.

    This probably has to do with the order in which the keys were pressed. If you press Alt first, does it work the way you want it to?

  • Alt key shortcut woes in InDesign CS6

    Greetings,
    Our company recently switched from Macs to PCs for design work. Now all of the keyboard shortcuts that had been assigned on the Mac and started with the Option key (e.g., Opt + numeric keypad 1) have switched to the Alt key on the PC (e.g., Alt + numeric keypad 1) and no longer work. All of the shortcuts that use Alt in combination with the Control or Shift keys along with a number from the numeric keypad work as expected. The cause apparently is tied to the Windows OS, which uses the Alt key to shift focus to application menus.
    My question is, has anyone found a straight-forward solution or workaround to this issue? Our designers count on those keyboard shortcuts to apply Paragraph, Character and Object styles. Having to revert to selecting from a palette rather than invoking the keyboard shortcut is truly costly in terms of time--a problem exacerbated by tight production deadlines. We have used all of the shortcut options that involve the shift and control keys, so switching the Alt key shortcuts isn't a legitimate option. We've look at using something like Auto Hotkey but have not successfully implemented that, and would prefer not to have to rely on that as a solution in the first place.
    Any assistance will be greatly appreciated.
    Thanks,
    Kevin

    Bob and Peter, thanks for your posts. Bob, I had previously come across the article by Sandee Cohen that you referenced. The technique there seems to provide a method to remap InDesign's keyboard shortcuts to allow use of the Alt key for events within ID, but I haven't been able to apply this strategy to custom shortcuts applied to paragraph, character and object styles. And the designer who developed our shortcuts very systematically used all of the available combinations (shift, option/alt, control, alone or in combos, and 0 through 9 on the numeric keypad). They had a great system on the Mac that unfortunately has now fallen apart on the PC.
    I'll keep digging and definitely welcome more advice. Thanks again!
    Kevin

  • Using the Alt key and numeric code from Character Map to insert special characters in Office 2010 programs

    I am used to using the ALT key and specific numbers for characters from the Character Map to place characters in Office programs like Outlook, Word, Excel. I have a new Lenovo T530 Laptop running the Windows 7 Professional Operating System. I have MS Office
    2010 Home and Business. In previous versions of Office, this feature worked first time, every time. On this machine, it is a 'no go' situation. Lenovo tech support says it is a Microsoft issue and Microsoft says it is a Lenovo issue. Either way, I'm having
    difficulty resolving the issue and getting this wonderful featrure working for me. Any suggestions and guidance would really be appreciated. Thank you. 

    Hi,
    Haven't been verified this myself, but since this feature require to use the numeric keypad to input the value, I suspect the cause of the issue is the laptop keyboard.
    To workaround this issue, try enable the numeric keypad from your laptop keyboard, normally, we can enable it by press
    Fn + Num Lock.
    After that, try insert characters again.
    Max Meng
    TechNet Community Support

  • Alt Key Stuck,Pls Help :(

    Hi everyone,im experiencing this for almost 2 months,and it doesnt allows me to play game,my keyboard just keeps pressing alt by itself,i need to use a program to disable alt so i can type,but i still cant play and i really use the alt key a lot in games.
    I've already searched a lot but I dont find a solution :(
    If someone knows how to fix this,pls help me :(

    Hi,
    In addition, this issue can also be caused by sticky key feature.
    Sticky Keys is an operating system feature designed to minimize the repeated pressing of keys. People typically trigger this behavior by accident when they quickly press a key many times consecutively.
    If you find the Sticky Keys feature particularly annoying, it can be turned off for good.
    1. Click Start → Control Panel → Ease of Access → Change how your keyboard works.
    2. Click “Set up Sticky Keys” (or press ALT+C). The “Sticky Keys setup” section of the Ease of Access Center.
    3. If there is a check in the box labeled “Turn On Sticky Keys”, un-check it.
    4. Un-check “Turn on Sticky Keys when SHIFT is pressed five times”. Screenshot of check boxes in the Sticky Keys configuration screen.
    5. Click the OK button to save your changes.
    Then, I suggest you restart Interface Device Access Service to check the results.
    Kate Li
    TechNet Community Support

  • MACBOOK air appears as though alt key is stuck

    My on screen keyboard is showing the cahracters as though the alt key is pressed.
    When I type it only brings up symbols. The alt key however is not stuck and the keyboard is new.
    How do I fix this problem?

    Hi rballiram,
    Thank you for visiting Apple Support Communities.
    It seems like your MacBook Air is recognizing that the option key is being pressed when it isn't; and you've confirmed by checking the Keyboard Viewer (onscreen keyboard) in OS X.
    This was a good isolating step, and if the behavior isn't caused by the keyboard itself, try booting into Safe mode next:
    Follow these steps to start up into Safe Mode.
    Be sure your Mac is shut down.
    Press the power button.
    Immediately after you hear the startup sound, press and hold the Shift key. The Shift key should be pressed as soon as possible after startup, but not before the startup sound.
    Release the Shift key when you see the Apple logo appear on the screen.
    After the Apple logo appears, it may take longer than usual to reach the login screen. This is because your computer is performing a directory check as part of Safe Mode.
    To leave Safe Mode, restart your computer without pressing any keys during startup.
    From:
    OS X: What is Safe Boot, Safe Mode? - Apple Support
    If your Mac behaves normally in Safe mode, try resetting the NVRAM (also called PRAM) and the System Management Controller using the steps at these links:
    How to Reset NVRAM on your Mac - Apple Support
    Intel-based Macs: Resetting the System Management Controller (SMC) - Apple Support
    Best Regards,
    Jeremy

  • Problems with FF orange-tab menu coming down when I use Alt keys

    I have had this small issue since yesterday which is more confusing than anything.
    When I go to type something, and use the alt keys plus the numbers for designs, the little orange FF tab on the top left-hand corner pulls down the drop-menu, and has 'Files' highlighted, plus it makes my computer make the Windows Default Beep, which I disabled because it was just annoying. I am having no notices of anything causing this, but this looks like the only browser that does it, because I went and played around with IE and Chrome, and nothing happened that I could see or hear of.
    Thanks for any insight!

    Try to switch on Num Lock if you need to use Alt + number keys.

Maybe you are looking for

  • Ability to Filter within an idividual perspective in a Tabular Model (cube)?

    I have a rather large Tabular model that I would like to use across 10 different reports as the requirements are identical, save for 1 aspect - the report goes out to 10 different companies. I need to be able to limit each result set by the individua

  • Advantage of Line Item Display

    In my companie, not all of the accounts have check the line item display in the Master Data, I like to know the advantages and disadvantage of have Line Item Display. I know that for the GL account is preferent to have it but for the others?? Thanks

  • Webservice to JDBC to SAP System to webservice using BPM

    Hi Frnz My requirement is i need to get data from webservice....... and i need to push that data to some Database... and the response from the Database to SAP system......and from that SAP system  the respone should come to the Webservie which is the

  • Release demand to SNP - Strange requirement

    Hi, We have some strange requirement during release demand from DP to SNP. We use demand planning system to plan future demands and release to SNP for supply planning. And we use TDP ( 10 days, a posting period) as storage bucket profile in DP and 9A

  • Unable to launch Photoshop CS6

    several programs in cs6 cloud subscription dont work at all and in the programs that do at least load some of the tools dont work. the latest is photoshop the text tool wont work