Can't capture key event in applet

Hi,
Currently i'm developing an applet. However, i fail to capture the key event in the applet. The key that i fail to capture is VK_TAB. Any idea to handle this?
Thanks in advance!

to capture key event, u need to
1. addKeyListener
2. focus on that component (yourApplet must focusable)

Similar Messages

  • Capture Key events

    I am trying to create a program to capture key events, regardless of where the focus is. For example, any time the user presses ctrl-t, I would like to call a particular method, if the user is in Microsoft Word, Internet Explorer, Halo, or any other application. However, a glass pane would not work, because all other key events will be needed by the current application. This would be identical to Microsoft' s ctrl-alt-del and Microsoft's alt-tab. Any ideas would be greatly appriciated. Post here or E-mail be at [email protected]

    This is not true, think of all the keylogger programs out there that allow you to do this.
    It's not a security issue.
    I also am wondering how to capture a key on a java application without it having focus. An example is a timer in a game. I should be able to be in a full screen game and hit F1 or Home or whatever I choose and have a timer start that will ding at me in 1 minute to let me know that my time is up.
    It is in a way similar to CTRL ALT DEL in that you don't ahve to be focused on anything in particular to use it but that isn't really the best analogy.
    If anyone can point me in the right direction to figure out how I would go about this, please tell me. Or if it is not possible for a program written in java to capture keypress without focus I would like to know that as well.
    You can do this in C and C++ but I would like to just add it in to an existing java program, thanks.

  • Capture Key Event - Feature Request

    Hello,
    We are using Forms 9.0.4 to build applications to be viewed over our intranet using Jinitiator. I am new to the development team and this is my first time using Forms. I am trying to find a way to capture key press events on a given field (we want to automatically search within a field each time the user enters a letter). I have seen nothing inherent in Forms to do this. There has been lots of metion of a PJC.
    1. Is there a plan to include such a trigger by default?
    2. If not, can someone please dumb-down PJCs for me?
    Thanks,
    ~Rob Lundeen

    yesterday in how to find which key the user presses we had a solution :
    http://www.oracle.com/technology/sample_code/products/forms/distributions/keyfilter.zip
    thx to indusvalley

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

  • How can I capture the event of selecting a listbar page item?

    Is there any way that I can capture the event of clicking/selecting a listbar page item (not just selecting the listbar page) from the listbar activeX control in TestStand 3.0?
    I was able to populate the list bar page with items, now how do I know if a user selects any one of those items?
    Thanks for your time and assistance,
    Mark

    Use the CursorMoved event.

  • Can JSF get Action Events from Applet  or  td

    following is a example of click different part of Command to get different effect.
    I wish get same effect as click on applet; In fact , I wish get the clicked point value (x and y ) relative to Component.
    Is this possible?
    Please help me to realization it. thanks!
    <html>
       <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
       <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
       <f:view>
          <head>                 
             <link href="styles.css" rel="stylesheet" type="text/css"/>
             <f:loadBundle basename="com.corejsf.messages" var="msgs"/>
             <title>
                <h:outputText value="#{msgs.indexWindowTitle}"/>
             </title>
          </head>
          <body>
             <h:form>
                <h:commandButton image="mountrushmore.jpg"
                   actionListener="#{rushmore.listen}"
                   action="#{rushmore.act}"/>
             </h:form>
          </body>
       </f:view>
    </html>
    package com.corejsf;
    import java.awt.Point;
    import java.awt.Rectangle;
    import java.util.Map;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ActionEvent;
    public class Rushmore {
       private String outcome = null;
       private Rectangle washingtonRect = new Rectangle(70, 30, 40, 40);
       private Rectangle jeffersonRect = new Rectangle(115, 45, 40, 40);
       private Rectangle rooseveltRect = new Rectangle(135, 65, 40, 40);
       private Rectangle lincolnRect = new Rectangle(175, 62, 40, 40);
       public void listen(ActionEvent e) {
          FacesContext context = FacesContext.getCurrentInstance();
          String clientId = e.getComponent().getClientId(context);
          Map requestParams = context.getExternalContext().getRequestParameterMap();
          int x = new Integer((String) requestParams.get(clientId + ".x"))
                .intValue();
          int y = new Integer((String) requestParams.get(clientId + ".y"))
                .intValue();
          outcome = null;
          if (washingtonRect.contains(new Point(x, y)))
             outcome = "washington";
          if (jeffersonRect.contains(new Point(x, y)))
             outcome = "jefferson";
          if (rooseveltRect.contains(new Point(x, y)))
             outcome = "roosevelt";
          if (lincolnRect.contains(new Point(x, y)))
             outcome = "lincoln";
       public String act() {
          return outcome;
    }

    final JList list = new JList(dataModel);
    MouseListener mouseListener = new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
             if (e.getClickCount() == 2) {
                 int index = list.locationToIndex(e.getPoint());
                 System.out.println("Double clicked on Item " + index);
    list.addMouseListener(mouseListener);

  • Capture desktop key event to control my screen capture app

    I want to write a screen capture program to capture screen when I am playing fullscreen game or other desktop window application. But the java screen capture program can only receive key or mouse event when it is focused. So how do I capture key event when I am focusing other app or fullscreen app?
    Do I have to use JNI and call some OS specific API. My target OS is WinXP. Help or suggestions are appreciated!!

    Hi All,
    I was wondering if there is a way to capture the top-most
    window or dialog box. This is something that will
    generally be running outside of the JVM....We,
    as programmers, need a Rectangle instance that describes the area
    of interest to be captured (i.e., location and size).
    Thus, a routine that interfaces to the Native windowing system (Toolkit?)
    might look something like:
    Rectangle rect = tk.getRectangleForTopMostComponent();
    Does anything like this exist?
    Thanks!
    - DocJava

  • Capture key and mouse event

    Hi,
    What I want to do is..
    when users click on a item such as text item and press the 'Ctrl' key, a message will
    appear.
    How can I capture the event ?
    Thanks.
    Ivan

    Duplicate thread. Please see the other one at:
    <p>capture key and mouse event

  • 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);
    }

  • Javafx multiple key events

    I have created a program in which a scene have two objects, and each object reacts when certain key is pressed, for example, when 1 is pressed , object 1 prints it's state,a and when 2 is pressed object 2 reports its state, but the program only work for object which is declared first in the scene
    following is an illustration
    import javafx.scene.input.KeyEvent;
    import javafx.scene.Scene;
    import javafx.scene.shape.Rectangle;
    import javafx.stage.Stage;
    * @author Vaibhav
    Stage{
        scene: Scene{
            content: [
                Rectangle{
                    onKeyPressed: function(ex:KeyEvent):Void{
                        println('first rectangle');
                Rectangle{
                    onKeyPressed: function(ex:KeyEvent):Void{
                        println('Second rectangle');
    }but it prints only for fist rectangle , is there a workaround

    Only the object, which has the focus, can react on key events. Apparently in your case the first object has the focus, therefore the second one does not receive the events. You can set the focus manually with requestFocus().

  • How to handle key events in iphone

    I want to be able to detect physical keyboard (e.g. bluetooth) events in an iOS app.
    In Mac, there is a class NSEvent which handles both keyboard and mouse events, and in ios (iphone/ipad) the counterpart of NSEvent is UIEvent which handles only touch events. I know ios API does not provide this functionality, but how can i handle key events in iphone???

    in my application header part of the page is common of all page. header.jsff contains comandmenuItem named "proceduralhelp". if I click proceduralhelp a pop up opens .
    in my login page when first time I open popup and press escape popup is not closing.
    rest of the cases after login escpe will cose the popup.
    only on the loginpage that to for the first time it is not closing when pressing up on escape key. (then we click on close button. and once again open the popup in loginpage now if we press escape it works).
    Thanks,
    Raghavendra.

  • 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 in a form

    Hello!
    Maybe I'm missing it, but how can one catch key events on a form?

    One way is to create a CustomItem and add this method:
    protected void keyPressed(int key) {
        System.out.println("Key pressed: "+key);
    }This will print the value of the key pressed when the CustomItem is focused.

  • 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

Maybe you are looking for

  • My disk utility says my hd is a disk image and has 1.26 gigs?

    it is a brand new 750 gb hd and It has been formatted and has mountain lion installed. I can boot off of it and it shows up as 750gb when I use a little external usb adapter. But not when its plugged in internally. I have tried to repair the disk in

  • Old messages suddenly downloaded again AND missing all text in Saved Emails

    I turned on my computer this morning (having made no changes to it in weeks) and suddenly all my emails for the last week (which is what I keep on the server) which had been previously downloaded, read, filed and/or deleted, were downloaded again. In

  • IOS5 sync problems for iPhone4

    IOS5 download sync problems for iphone4 Can't now get NOTES and CALENDAR synced, just deletes any information inserted since download. Furthermore some music files have been corrupted. My PC has Windows XP and IE8. Had no problems with previous iphon

  • Bom upload using bdc

    While uploading bom using bdc method how to upload item details into subscreen table.explain table control in bdc

  • Missing classes at Oracle 8i JServer

    does somebody know, which CLASSPATH is missing for the JServer context [->] when i wanna connect to the AURORA IIOP Port 1040 at my linuxbox with JDeveloper I'll get that message: org.omg.CORBA.OBJECT_NOT_EXISTS[completed=MAYBE] I belife, that a CLAS