JPanel key events blocked by JToolBar?

I have a JPanel that I'm drawing on, and the frame containing the panel also holds a JToolBar. The JPanel doesn't catch any KeyEvents, which I really would like to monitor.
I have overridden isFocusable() as suggested in another thread like so:
public boolean isFocusable()
return true;
}My JPanel still doesn't catch KeyEvents, unless I get rid of the JToolBar. It seems that the controls in the toolbar don't pass the focus on to the panel. How do I change this behavior, without removing the toolbar?

Found the answer elsewhere.
I now add a "requestFocus()" call in my mousePressed event handler, and the JPanel catches the key events again.

Similar Messages

  • JPanel can't receive key events

    I have a single JPanel added to the content pane of a JFrame.
    I want to itercept key events by adding a KeyListener to the JPanel.
    If I do it, I don't receive key events.
    To solve the problem I identified two ways:
    - add the KeyListener to the JFrame's content pane
    - invoke setFocusable(true) on the JPanel (available only since 1.4)
    I can't use the former because I want to bind the the KeyListener to the JPanel, and I can't use the latter because I don't want to have dependencies on jdk 1.4.
    Can anyone suggest a way to solve the problem as simple as calling setFocusable() but available also for older versions of java?

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class KeyListenTest {
         public static void main(String[] args) {
              JPanel panel = new JPanel();
              panel.addKeyListener(new KeyAdapter() {
                   public void keyTyped(KeyEvent e) {
                        System.out.println(e);
              JFrame frame = new JFrame();
              frame.getContentPane().add(panel);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setSize(400,300);
              frame.setVisible(true);
              panel.requestFocus();
    }The panel must be displayable and visible, so you have to make the call after frame.setVisible(true), however if you don't have any other components that will take the focus away from your panel, this should do it for you. If you want the use to be able to shift focus to your panel, then just add a mouse listener to the panel with a mousePressed(MouseEvent) method that calls the requestFocus() method on the panel.

  • Tricky Block Key Events in JTable

    Iam using a JTable . I donot want to use CustomTableModel to block the key events but I want to consume the keyevents as and when the user types in . In other words block the user from editing the cell but I donot want to make the cell un-editable . THis is a bit tricky I hope I have a solution for this

    Not sure exactly what you want but maybe this will give you some ideas:
    table = new JTable(model)
         protected void processKeyEvent(KeyEvent e)
              int column = table.getSelectedColumn();
              int row = table.getSelectedRow();
              if( row == ?? && column == ?? )
                   e.consume();
               else
                   super.processKeyEvent(e);
    };

  • JPanel cannot recieve Key Events?

    Hi. I'm trying to make a simple game, which recieves input from the arrow keys and spacebar. The drawing is done inside a paintComponent() method in a JPanel. Therefore, the key events should also be handled in the same JPanel. I can call the addKeyListener() method on the JPanel, but it does not recieve key events. I've tried calling setFocusable(true) but it doesn't seem to do anything. If JPanel can't recieve key events (it can recieve mouse events fine), I have to handle the events in the JFrame, which I'm hesitant to do. My book does it in an applet and applets can recieve key events fine, but I want to make an application.
    No working source code here, try to figure out what I'm saying.
    Thanks.

    Please help me. I did help you. I gave you a link to the tutorial that shows that proper way to do this.
    All Swing components use Key Bindings so you might as well take the time to understand how they work.
    Anyway, based on your vague description of the problem we can't help you because we don't know the details of your code.

  • Need key events in JPanel

    I can't receive key events in a JPanel, and need to figure out how. While the JDialog I added my JPanel to originally could catch these, once I added more components (like a JTextBox and JCheckBox), neither my panel nor dialog caught any key events at all. Isn't there some way when my panel has focus to capture and respond to key press events?
    Thanks,
    Mark McKay
    http://www.kitfox.com

    This works for a JFrame, didn't test it on a JDialog:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class PanelEvents extends JFrame
         public PanelEvents()
              JPanel main = new JPanel();
              main.setPreferredSize( new Dimension(300, 300) );
              main.setFocusable(true);
              getContentPane().add( main );
              main.addMouseListener( new MouseAdapter()
                   public void mousePressed(MouseEvent e)
                        e.getComponent().requestFocusInWindow();
                        System.out.println(e.getPoint());
              main.addKeyListener( new KeyAdapter()
                   public void keyTyped(KeyEvent e)
                        System.out.println(e.getKeyChar());
              getContentPane().add(new JTextField(), BorderLayout.NORTH);
         public static void main(String[] args)
              JFrame frame = new PanelEvents();
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }

  • How to block JTree key event listeners

    I have a JToolbar I am managing keyboards events for (e.g. PageUp, PageDown, right, left, up, down). I also have a JTree in another panel. I have to use 'Alt + PageUp' instead of PageUp because, if I use 'PageUp' (without also using the Alt key), and, the JTree gets the focus, then the JTree will respond to 'PageUp' instead of my JToolbar.
    I have my key actions in a 'getKeystrokeActions()' method which I pass the JToolbar into so I tried passing the JTree to the same method. This doesn't quite do what I want as both components now respond to a 'PageUp' key event.
    There must be some way to tell the JTree not to handle key events but I can't seem to find it. Any help much appreciated.

    Remove the key listeners?
    JTree tree = new JTree();
    for(KeyListener listener : tree.getKeyListeners()) {
        tree.removeKeyListener(listener);
    }Another option would be to just do
    tree.setFocasable(false);

  • Help with understanding key event propagation

    Hello,
    I am hoping someone can help me understand a few things which are not clear to me with respect to handling of key events by Swing components. My understanding is summarized as:
    (1) Components have 3 input maps which map keys to actions
    one for when they are the focused component
    one for when they are an ancestor of the focused component
    one for when they are in the same window as the focused component
    (2) Components have a single action map which contains actions to be fired by key events
    (3) Key events go to the currently focused component
    (4) Key events are consumed by the first matching action that is found
    (5) Key events are sent up the containment hierarchy up to the window (in which case components with a matching mapping in the WHEN_IN_FOCUSED_WINDOW map are searched for)
    (6) The first matching action handles the event which does not propagate further
    I have a test class (source below) and I obtained the following console output:
    Printing keyboard map for Cancel button
    Level 0
    Key: pressed C
    Key: released SPACE
    Key: pressed SPACE
    Level 1
    Key: pressed SPACE
    Key: released SPACE
    Printing keyboard map for Save button
    Level 0
    Key: pressed SPACE
    Key: released SPACE
    Level 1
    Key: pressed SPACE
    Key: released SPACE
    Printing keyboard map for Main panel
    Event: cancel // typed SPACE with Cancel button having focus
    Event: save // typed SPACE with Save button having focus
    Event: panel // typed 'C' with panel having focus
    Event: panel // typed 'C' with Cancel button having focus
    Event: panel // typed 'C' with Save button having focus
    I do not understand the following aspects of its behaviour (tested on MacOSX although I believe the behaviour is not platform dependent):
    (1) I assume that the actions are mapped to SPACE since the spacebar clicks the focused component but I don't explicitly set it?
    (2) assuming (1) is as I described why are there two mappings, one for key pressed and one for key released yet the 'C' key action only has a key pressed set?
    (3) assuming (1) and (2) are true then why don't I get the action fired twice when I typed the spacebar, once when I pressed SPACE and again when I released SPACE?
    (4) I read that adding a dummy action with the value "none" (i.e. the action is the string 'none') should hide the underlying mappings for the given key, 'C' the my example so why when I focus the Cancel button and press the 'C' key do I get a console message from the underlying panel action (the last but one line in the output)?
    Any help appreciated. The source is:
    import javax.swing.*;
    public class FocusTest extends JFrame {
         public FocusTest ()     {
              initComponents();
              setTitle ("FocusTest");
              setLocationRelativeTo (null);
              setSize(325, 160);
              setVisible (true);
         public static void main (String[] args) {
              new FocusTest();
    private void initComponents()
         JPanel panTop = new JPanel();
              panTop.setBackground (java.awt.Color.RED);
    JLabel lblBanner = new javax.swing.JLabel ("PROPERTY TABLE");
    lblBanner.setFont(new java.awt.Font ("Lucida Grande", 1, 14));
    lblBanner.setHorizontalAlignment (javax.swing.SwingConstants.CENTER);
              panTop.add (lblBanner);
              JPanel panMain = new JPanel ();
              JLabel lblKey = new JLabel ("Key:");
              lblKey.setFocusable (true);
              JLabel lblValue = new JLabel ("Value:");
    JTextField tfKey = new JTextField(20);
    JTextField tfValue = new JTextField(20);
    JButton btnCancel = new JButton (createAction("cancel"));     // Add a cancel action.
    JButton btnSave = new JButton (createAction("save"));          // Add a sve action.
              panMain.add (lblKey);
              panMain.add (tfKey);
              panMain.add (lblValue);
              panMain.add (tfValue);
              panMain.add (btnCancel);
              panMain.add (btnSave);
              add (panTop, java.awt.BorderLayout.NORTH);
              add (panMain, java.awt.BorderLayout.CENTER);
    setDefaultCloseOperation (javax.swing.WindowConstants.EXIT_ON_CLOSE);
    // Add an action to the panel for the C key.
              panMain.getInputMap (JComponent.WHEN_IN_FOCUSED_WINDOW).put (KeyStroke.getKeyStroke (java.awt.event.KeyEvent.VK_C, 0), "panel");
              panMain.getActionMap ().put ("panel", createAction("panel"));
              // FAILS ???
              // Add an empty action to the Cancel button to block the underlying panel C key action.
    btnCancel.getInputMap().put (KeyStroke.getKeyStroke (java.awt.event.KeyEvent.VK_C, 0), "none");
    // Print out the input map contents for the Cancel and Save buttons.
    System.out.println ("\nPrinting keyboard map for Cancel button");
    printInputMaps (btnCancel);
    System.out.println ("\nPrinting keyboard map for Save button");
    printInputMaps (btnSave);
              // FAILS NullPointer because the map contents are null ???
    System.out.println ("\nPrinting keyboard map for Main panel");
    // printInputMaps (panMain);
    private AbstractAction createAction (final String actionName) {
         return new AbstractAction (actionName) {
              public void actionPerformed (java.awt.event.ActionEvent evt) {
                   System.out.println ("Event: " + actionName);
    private void printInputMaps (JComponent comp) {
         InputMap map = comp.getInputMap();
         printInputMap (map, 0);
    private void printInputMap (InputMap map, int level) {
         System.out.println ("Level " + level);
         InputMap parent = map.getParent();
         Object[] keys = map.allKeys();
         for (Object key : keys) {
              if (key.equals (parent)) {
                   continue;
              System.out.println ("Key: " + key);
         if (parent != null) {
              level++;
              printInputMap (parent, level);
    Thanks,
    Tim Mowlem

    Use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.
    1) In the Metal LAF the space bar activates the button. In the Windows LAF the Enter key is used to activate the button. Therefore these bindings are added by the LAF.
    2) The pressed binding paints the button in its pressed state. The released binding paint the button in its normal state. Thats why the LAF adds two bindings.
    In your case you only added a single binding.
    3) The ActionEvent is only fired when the key is released. Same as a mouse click. You can hold the mouse down as long as you want and the ActionEvent isn't generated until you release the mouse. In fact, if you move the mouse off of the button before releasing the button, the ActionEvent isn't even fired at all. The mouse pressed/released my be generated by the same component.
    4) Read (or reread) the [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html#howto]How to Remove Key Bindings section. "none" is only used to override the default action of a component, it does not prevent the key stroke from being passed on to its parent.

  • Is using key events really that hard?

    I am trying to implement a keyListener for my application, and it seems
    way harder than it should be. My application is simple: A JFrame
    with one button and one JPanel upon which I draw. When I click
    in the JPanel and type, I want things to happen.
    After much looking, it seems I have to not only implement KeyListener,
    but also MouseListener, so when the mouse enters I can call
    requestFocusInWindow().
    That seems to work sometimes, but not when I leave and come back,
    and not always when the application first appears.
    So do I also have to implement FocusListener?
    Why is this so hard to do? MouseListener is very easy to implement,
    but KeyListener seems to be a huge pain in the butt.
    Can someone point me to a simple tutorial or example that just
    has a few swing elements, and processes key events?
    I feel like with Java I often try enough things until it finally works,
    and never really understand why, and what it was that fixed it.
    The documentation and API does not fully describe everything one
    needs to know to use the API "properly". Am I the only one frustrated
    by this? I have programmed in Java/Swing for years, and JUST LAST
    WEEK discovered that when implementing paint in swing, one should
    override paintComponent and not paint. But then why does overriding
    paint usually work? There are too many quirks in Java that let you
    get away with doing things wrong, and then suddenly, your application
    is broken. It wouldn't be so bad if the API was more clear on some of
    these suble issues.
    Thanks,
    Chuck.

    How to Use Key Bindings

  • Getting key events without a jcomponent...

    Is it possible to get key events without adding a keylistener to a jpanel? I want a class of mine to manage input of it's own, but it has no reference to a jpanel. They don't necessarily have to be KeyEvents, but just some way to detect if a key has been pressed (like the arrow keys). How can I do this? Thanks.

    Lots of components can listen for key events.
    What does your class subclass?It doesn't subclass anything. I am creating a custom menu system for my game using images I have made for the tileset. I would like it to handle some keyboard events of its own. (Like if the down arrow is pressed, it will move the focus down to the next component on its own). Right now I am currently passing the key events from my fullscreen jpanel to the menu class and it is handling them that way. Thanks.

  • Key events on the glasspane

    I'm trying to develop a glasspane that captures the key events as well as the mouse events.. In this example, the mouse events happen exactly the way I want them to, but I cannot for the life of me get a key event to register.. I've tried capturing keyTyped(), keyPressed(), and keyReleased() to no avail.. Dukes to whoever shows me the light,
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class BCInv
        extends JFrame {
      JScrollPane jScrollPane1 = new JScrollPane();
      JTextArea jTextArea1 = new JTextArea();
      JScrollPane jScrollPane2 = new JScrollPane();
      JTable jTable1 = new JTable();
      JButton jButton1 = new JButton();
      public BCInv() {
        jbInit();
        setVisible(true);
        getGlassPane().setVisible(true);
        //here I'm adding both listeners in the same manner
        getGlassPane().addMouseListener(new BCInv_mouseAdapter());
        getGlassPane().addKeyListener(new BCInv_keyAdapter());
      public void jbInit() {
        setSize(new Dimension(611, 423));
        getContentPane().setLayout(null);
        jScrollPane1.setBounds(new Rectangle(9, 275, 574, 110));
        jTextArea1.setText("jTextArea1");
        jScrollPane2.setBounds(new Rectangle(10, 13, 573, 175));
        jButton1.setBounds(new Rectangle(196, 217, 89, 42));
        jButton1.setText("jButton1");
        this.getContentPane().add(jScrollPane1, null);
        this.getContentPane().add(jScrollPane2, null);
        this.getContentPane().add(jButton1, null);
        jScrollPane2.getViewport().add(jTable1, null);
        jScrollPane1.getViewport().add(jTextArea1, null);
      public static void main(String[] args) {
        BCInv BC = new BCInv();
      //this key stuff here never executes..
      void BCkey(KeyEvent e) {
        System.out.println("A key was typed: '"+e.getKeyChar()+"' = "+e.getKeyCode());
      class BCInv_keyAdapter extends java.awt.event.KeyAdapter {
        BCInv_keyAdapter() {}
        public void keyTyped(KeyEvent e) {
          BCkey(e);
      //All this mouse stuff works great..
      void BCmouseClicked(MouseEvent e) {
        System.out.println("click");
        Point glassPanePoint = e.getPoint();
        boolean inButton = false;
        boolean inMenuBar = false;
        Component component = null;
        Container container = getContentPane();
        Point containerPoint = SwingUtilities.convertPoint(
            getGlassPane(),
            glassPanePoint,
            getContentPane());
        component = SwingUtilities.getDeepestComponentAt(
            container,
            containerPoint.x,
            containerPoint.y);
        if (component == null) {
          return;
        System.out.println("underlying component="+component.toString());
      class BCInv_mouseAdapter
          extends java.awt.event.MouseAdapter {
        BCInv_mouseAdapter() {}
        public void mouseClicked(MouseEvent e) {
          BCmouseClicked(e);
    }

    * @author nordj
    public class GlassPane extends JPanel {
         private boolean okToLooseFocus = true;
         public GlassPane() {
              setName("GlassPane");
              setVisible(false);
              super.setOpaque(false);
              //super.setBackground(new Color(0x00,0x00,0x00,0x88));
              //super.setForeground(new Color(0x00,0x00,0x00,0xFF));
              // trap keyboard & mouse events.
              //enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);
              enableEvents(0xFFFFFFFFFFFFFFFFl);
              setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
              setInputVerifier(new GlassPaneInputVerifier());
         /* (non-Javadoc)
          * @see java.awt.Component#processMouseEvent(java.awt.event.MouseEvent)
         protected void processMouseEvent(MouseEvent e) {
              if (e.getID() == e.MOUSE_CLICKED) {
                   Toolkit.getDefaultToolkit().beep();
                   e.consume();
              super.processMouseEvent(e);
         /* (non-Javadoc)
          * @see java.awt.Component#processKeyEvent(java.awt.event.KeyEvent)
         protected void processKeyEvent(KeyEvent e) {
              Toolkit.getDefaultToolkit().beep();
              super.processKeyEvent(e);
         /* (non-Javadoc)
          * @see java.awt.Component#processEvent(java.awt.AWTEvent)
         protected void processEvent(AWTEvent e) {
              // TODO Auto-generated method stub
              //System.err.println(e);
              super.processEvent(e);
         /* (non-Javadoc)
          * @see java.awt.Component#setVisible(boolean)
         public void setVisible(boolean visible) {
              okToLooseFocus = !visible;
              super.setVisible(visible);
              if (visible) {
                   requestFocusInWindow();
         /* (non-Javadoc)
          * @see java.awt.Component#paint(java.awt.Graphics)
         public void paint(Graphics g) {
              g.setColor(new Color(0xFF,0x00,0x00,0x88));
              g.fillRect(0,0,getWidth(), getHeight());
          * Simple hack to stop the RootPane loosing focus when it's visible
          * @author nordj
         private class GlassPaneInputVerifier extends InputVerifier {
              /* (non-Javadoc)
               * @see javax.swing.InputVerifier#verify(javax.swing.JComponent)
              public boolean verify(JComponent input) {
                   //return (!isVisible());
                   return okToLooseFocus;
    }

  • Getting Key Events during animation loop

    I'm having a problem recieving Key events during my animation loop. Here is my example program
    import java.awt.*;
    import java.awt.image.BufferStrategy;
    import javax.swing.JPanel;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import java.util.ArrayList;
    import java.awt.event.*;
    import java.util.Iterator;
    import GAME.graphics.Animation;
    import GAME.sprites.MainPlayer;
    import GAME.util.MapData;
    import GAME.input.*;
    public class ImageTest extends JFrame {
        private static final long DEMO_TIME = 20000;
        private Animation      anim;
        private MainPlayer     mPlayer;
        private MapData               mapData;
        private InputManager      inputManager;
        private GameAction moveLeft;
        private GameAction moveRight;
        private GameAction exit;
        public ImageTest()
         requestFocus();
         initInput();
         setSize(1024, 768);
         setUndecorated(true);
         setIgnoreRepaint(true);
         setResizable(false);
         loadImages();
         anim = new Animation();
            mPlayer = new MainPlayer(anim);
            setVisible(true);
            createBufferStrategy(2);
            animationLoop();
         // load the player images
         private void loadImages()
              // code that loads images...
         // Initialize input controls
         private void initInput() {
            moveLeft = new GameAction("moveLeft");
            moveRight = new GameAction("moveRight");
            exit = new GameAction("exit",
                GameAction.DETECT_INITAL_PRESS_ONLY);
            inputManager = new InputManager(this);
            inputManager.setCursor(InputManager.INVISIBLE_CURSOR);
            inputManager.mapToKey(moveLeft, KeyEvent.VK_LEFT);
            inputManager.mapToKey(moveRight, KeyEvent.VK_RIGHT);
            inputManager.mapToKey(exit, KeyEvent.VK_ESCAPE);
        // Check player input
        private void checkInput(long elapsedTime) {
            if (exit.isPressed()) {
                System.exit(0);
            if (mPlayer.isAlive()) {
                float velocityX = 0;
                if (moveLeft.isPressed()) {
                    velocityX-=mPlayer.getMaxSpeed();
                if (moveRight.isPressed()) {
                    velocityX+=mPlayer.getMaxSpeed();
                mPlayer.setVelocityX(velocityX);
        // main animation loop
        public void animationLoop() {
            long startTime = System.currentTimeMillis();
            long currTime = startTime;
            while (currTime - startTime < DEMO_TIME) {
                long elapsedTime =
                    System.currentTimeMillis() - currTime;
                currTime += elapsedTime;
                checkInput(elapsedTime);
                mPlayer.update(elapsedTime);
                // draw and update screen
                BufferStrategy strategy = this.getBufferStrategy();
                Graphics2D g = (Graphics2D)strategy.getDrawGraphics();
                if (!(bgImage == null))
                     draw(g);
                     g.dispose();
                     if (!strategy.contentsLost()) {
                         strategy.show();
                // take a nap
                try {
                    Thread.sleep(20);
                catch (InterruptedException ex) { }
        public void draw(Graphics g) {
            // draw background
            if (bgImage != null)
                         // draw image
                 g.drawImage(mPlayer.getImage(), (int)mPlayer.getX(), (int)mPlayer.getY(), null);
    }My InputManager implements KeyListener. When running print statements on my Key events, they are not being called until after the animation demo is done running. Can someone help me with getting the Key events to update during the animation loop? Thank you!

    I've used the post from Abuse on the following thread with success. Maybe it will clue you in to what you might be doing wrong:
    http://forum.java.sun.com/thread.jsp?forum=406&thread=498527

  • How to catch key events

    Hello!
    I have a component which extends JPanel. Now I dynamically add a JTextField as a child to this component. The problem is: when the textfield has focus, how can I get key events in my panel before the textfield gets them (and maybe intercept them so that the textfield doesn't get them at all)?
    Background: the component is a self written table and the textfield is an editor. Now I have to make sure that when I am editing and press e.g. "cursor up", that not the textfield will get this key event but the table (which should traverse the current cell then ...)
    The problem is: I cannot change the textfield (extend it or something) because a possible solution has to work with any java awt "Component" (or at least with JComponent).
    Any help very appreciated.
    Michael

    Hello,
    implement the keyListener interface for the Extended component...
    and in Keypressed method
    keyPressed(keyEvent){
    // do all ur reuirements here
    //and comsume the keyEvent...
    hope this helps

  • Key event without focus

    Hi,
    Could you tell me how to get F1 key event which is
    nothing to do with any control's focuses?
    For example, suppose there's a button saying "F1 exit",
    and the focus is on some other button.
    In such case, if user pushes F1, program should exits.
    That's what I want to do.
    Thank you.

    For example:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Example {
        public static void main(String[] args) {
            JPanel p = new JPanel();
            p.add(new JButton("sample button"));
            Action action = new AbstractAction("homer") {
                public void actionPerformed(ActionEvent evt) {
                    System.out.println("DOH!");
            KeyStroke stroke = KeyStroke.getKeyStroke("F1");
            Object key = action.getValue(Action.NAME); //homer
            p.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, key);
            p.getActionMap().put(key, action);
            JFrame f = new JFrame("Example");
            f.setContentPane(p);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • 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.

  • Detect key events on anything

    If I have a JFrame with many components on it, how do I detect if a key is pressed, without having to add a listener to every component? For example, how can I check for the escape key being pressed, but not having to have componentN.addKeyListener(this); for everything?
    Thanks
    US101

    The correct way to collect the key events is the following:
    from java 1.2 to java 1.3 use the FocusManager. This class can be found in the javax.swing package. You would then need to extend the DefaultFocusManager and override specific behavior.
    for java 1.4 use the KeyBoardFocusManager. This class can be found in the java.awt package.
    Please see the following for a better explanation:
    http://java.sun.com/j2se/1.4/docs/api/java/awt/doc-files/FocusSpec.html
    Thanks for your time,
    Nate

Maybe you are looking for

  • How Can I Sort/Order My Photos By 'Modified Date' ?! Not Taken Date :/  iOS5

    Hii, I'm From Panama... And I'm havin' this issue, Ok Let me explain to you guys (I hope u can help me out).      Look, Before I Updated my iPod Touch From iOS 4.3.5 to iOS 5 I had my photos (an specific album) sort by Modified Date, But now that I u

  • Return against Move order issue

    We need to get back the material in the inventory stock issued by move order transaction. Example: 10 bag Cement issued by Move order. Now my stock is less by 10 bag. Now from these 10 bags 2 bags is returned to stock which will increase the stock by

  • Launch appication in new window.

    Hi, In ITS i am trying to launch the PDF file from the click of the button. It is correctly opening the PDF file. Problme is it is opening in the same window. I need the appication to be launched in different window. Is there a way i can open a file

  • WLC 5508 Smartnet

    When contracting an SMARTNET for a WLC, do we have to consider the actual number of AP's or the maximun? For example, a WLC-5508-50-K9 can handle up to 50 AP's, but at the moment there is only 24 AP's in the network. Which SMARTNET do I need? CON-SNT

  • Safari just won't open! Icon bounces then stops.

    I've just finished re-installing OSX 10.3.9 and Safari 1.3.1 and after using Safari for a couple of days, all of a sudden it won't open. After clicking on the icon in the dock, it bounces about 6 or 8 times and then just sits down again and stops. No