How Keyboard & Mouse Events are handled in java?

Hi
How Keyboard & Mouse Events are handled in java?
Kindly brief, how a key typed in the keyboard is sensed and it is entered in JTextField?
or
Pls. give me some links.
Am going to send the events from external device (like keyboard) to OS and from that I need to capture that event in Java Swing?
Pls. drop in a bit. So that it will be helpfull to me.
Thanks in advance,
bee

Actualy am very much aware of using KeyListener and MouseListener. I am in need of internal details,
how typing a key in keyboard is captured by KeyListener? How the event is passed to java swing and and it is fired to keylistener.
Pls. help me.
Thanks
bee

Similar Messages

  • All buttons in all files are now showing error: Mouse events are permitted only for button instances.

    Somebody please help:
    I've taught myself enough with Flash to customize a
    fully-Flash template for my wife's website, and two of the buttons
    didn't do what I wanted them to in Actionscript. They then began
    giving me the message:
    **Error** Symbol=sub_butt1, layer=Layer 4, frame=1:Line 1:
    Mouse events are permitted only for button instances
    on (rollOver) {
    **Error** Symbol=sub_butt1, layer=Layer 4, frame=1:Line 4:
    Mouse events are permitted only for button instances
    on (releaseOutside, rollOut) {
    Total ActionScript Errors: 2 Reported Errors: 2
    Not only do I not know how to fix this, the same message
    comes up for every single button in the entire fla I had saved,
    plus earlier versions where I hadn't even messed with the buttons
    yet.
    Any suggestions?

    Hello Corbett,
    The error is saying that you are trying to apply a button
    action to something
    other than a button. Often this happens when you select the
    frame that the
    button is on instead of the actual button, thus applying the
    action to the
    frame instead of the button.
    Make sure you select the button on the stage and then apply
    the actions there.
    You'll probably have to remove the action from the frame
    before it will work
    (looks like it's on Layer 4 frame 1).
    Good luck!
    Jesse H.
    Adobe Community Expert
    My site:
    http://www.jharding.com
    Free Blog Radio:
    http://www.tornadostream.com
    > Somebody please help:
    > I've taught myself enough with Flash to customize a
    fully-Flash
    > template for
    > my wife's website, and two of the buttons didn't do what
    I wanted them
    > to in
    > Actionscript. They then began giving me the message:
    >
    > **Error** Symbol=sub_butt1, layer=Layer 4, frame=1:Line
    1: Mouse
    > events are
    > permitted only for button instances
    > on (rollOver) {
    > **Error** Symbol=sub_butt1, layer=Layer 4, frame=1:Line
    4: Mouse
    > events are
    > permitted only for button instances
    > on (releaseOutside, rollOut) {
    > Total ActionScript Errors: 2 Reported Errors: 2
    >
    > Not only do I not know how to fix this, the same message
    comes up for
    > every
    > single button in the entire fla I had saved, plus
    earlier versions
    > where I
    > hadn't even messed with the buttons yet.
    > Any suggestions?

  • When both plug-in objects and jQuery mouse events are present, Firefox re-starts the plug-in object (eg Flash movie) after a jQuery mouse event occurs. This doesn't happen in any other browser. How can I get around this?

    Please check http://www.syus.com for an example. There is a Flash movie underneath the main navigation. The main navigation has a jQuery mouse event, and when you mouse over a button in the main navigation, the Flash movie re-starts. I can confirm that this happens not only on Flash swf files, but on standard <object> YouTube embeds.

    Ok, I promise this is my last post without your help. I did some more troubleshooting and it only seems to happen when jQuery appends elements to the body that were previously invisible. In other words, I can simply change the css in jQuery from using element.css('display','inline'), but if I try to use something like slideDown or other jQuery tooltip functions that append and/or remove elements or style definitions it causes the "object restart" bug.
    It is impossible for any developer to eliminate this bug without changing the actual source of jQuery, which I can't do. My only other option is not to use sophisticated show/hide jQuery elements like drop-down menus and tooltips on the same page as an embedded object, but I don't want to do this since Safari, Chrome and even IE (dear God) users won't have a problem with this. I think this is a major major bug that should be fixed in Firefox 4 as more and more sites will be looking to use the latest jQuery plugins.

  • How resource files(.rc) are implemented in java

    I want to know how resource files are implemented in java. I am using a window98 as OS.
    Thank you
    Abu_ramla

    I wonder if this might help:
    ResourceBundle rbd = ResourceBundle.getBundle("Filename");
    to get a property out of the resourceBundle use:
    String varname = (String) prb.getObject("propName");
    As allways, check the API
    Hope this helps
    Elouiza

  • Don't want random keyboard & mouse events to wake from sleep

    is there any way to prevent a random keyboard press or mouse movement from waking up the computer? a terminal setting or something? ideally, i'd just like to use the power button to do this--or at the very least to completely disable the mouse's ability to wake the machine, and specify a certain key or something.
    seems like an obvious setting that's missing...or that i'm overlooking...?
    thanks!
    various Macs   Mac OS X (10.4.8)  

    markhimself wrote:
    Is there any way to disable the mouse from waking from sleep mode? Additionally, can you disable the mouse from waking the display from display sleep only? And is this done the same way?
    Thanks.
    If it's a BlueTooth mouse you can uncheck the option in the Keyboard & Mouse preferences.

  • Mouse Events are slow

    Hello everyone,
    I'm currently working on an standard as3 (1024x768) app that
    is running inside a chromeless Air window to take advantage of the
    transparency.
    All my tests where done using windows XP professional and AIR
    1.0 (the same problem existed in beta3).
    The issue I'm having is related with Mouse Events. Somehow
    the events take a lot of time to reach the swf file when the user
    clicks inside the transparent window.
    It's natural that the app runs slower inside a transparent
    window (the framerate drops) but I wasn't expecting the clicks to
    suffer from such delay (it takes sometimes 2-5sec).
    The app is very CPU intensive and the transparencies make it
    worse. Something inside the AIR framework is not dispatching the
    events properly.
    I say this because I tried using the virtualMouse class from
    senocular together with a socket to simulate the mouse clicks and
    that did the trick.
    In conclusion:
    Something in the AIR framework for windows XP is messing up
    the dispatch of the Mouse events when the app is under heavy cpu
    usage inside a chromeless window. I click on the window and it
    takes 1-2sec to receive the click event.
    However when I dispatch the MouseEvent.CLICK myself using
    the virtual mouse class the application immediately receives the
    event.
    I know this is a strange bug and not many people will have
    this problem, but I would like to know from someone with knowledge
    of the runtime why this could be happening.
    Thank you
    Tiago Bilou

    Hello everyone,
    I'm currently working on an standard as3 (1024x768) app that
    is running inside a chromeless Air window to take advantage of the
    transparency.
    All my tests where done using windows XP professional and AIR
    1.0 (the same problem existed in beta3).
    The issue I'm having is related with Mouse Events. Somehow
    the events take a lot of time to reach the swf file when the user
    clicks inside the transparent window.
    It's natural that the app runs slower inside a transparent
    window (the framerate drops) but I wasn't expecting the clicks to
    suffer from such delay (it takes sometimes 2-5sec).
    The app is very CPU intensive and the transparencies make it
    worse. Something inside the AIR framework is not dispatching the
    events properly.
    I say this because I tried using the virtualMouse class from
    senocular together with a socket to simulate the mouse clicks and
    that did the trick.
    In conclusion:
    Something in the AIR framework for windows XP is messing up
    the dispatch of the Mouse events when the app is under heavy cpu
    usage inside a chromeless window. I click on the window and it
    takes 1-2sec to receive the click event.
    However when I dispatch the MouseEvent.CLICK myself using
    the virtual mouse class the application immediately receives the
    event.
    I know this is a strange bug and not many people will have
    this problem, but I would like to know from someone with knowledge
    of the runtime why this could be happening.
    Thank you
    Tiago Bilou

  • How events are handled in mac os x

    Hi I am trying to write an application to handle driver asynchronous event.. it should be similar to iwevent in our linux.. can anybody give me an idea as how to start with it.. and what are all the API's used for the same..
    Thanks in advance

    I suggest you do a google search for "events" on developer.apple.com (use this link) and you should find everything you are looking for on the subject or pointers to it.  Berkeley Unix and the Mach kernel are the underlying architectures for OSX and you cannot count on extrapolating linux to OSX.

  • Lots of lags in basic finder operations - mouse events are not recognized

    Hi there,
    since 10.6.7 I'm experiencing lots of problems with my Mac mini 2,4Ghz Intel core duo / 4 GB RAM / 140GB free disc space. I recently updated to Lion which I hoped would fix some of this problems - turned out to be a dream. Some Time/Apps later all the problems show up again. I already searched the web for solutions and did the following:
    resetting PRAM, booting in safe mode, deleting startup items, complete new system installation, and apps, updating software, killing dashbord (read it somewhere), adjusting mouse preferences, checking with hardware test, removing RAM bars to check if there is a problem, memtest, used "lion cache cleaner" for optimizing RAM, deleting caches, switching vom 64 to 32 bit and vice versa,  etc. ... no effect!
    Activity monitor does not show any unusual peaks (as far as I can tell) in performance (cpu, ram, etc.)
    1) Basic finder operations often lag. E.g. opening an external USB drive, opening internal drive, opening upper registers(menues), etc. Sometimes up to 5 seconds delay, which can be really annoying during work. What is more, this happens in almost all Apps when I try to access the file system.
    2) iTunes videos from the store lag quite heavy. It's almost impossible to watch a movie due to the hangups
    3) Mouse clicks/moves sometimes/often are not (or very late) recognized by finder/apps. (e.g. CS5 Photoshop,when triing to move a layer I often need to use the arrow keys of the keyboard to have an effect, mouse is just ignored  & simple movement of files will only happen after I tried it 2-3 times)
    4) Entering text in form fields, like logins, community posts, ... is a real pain since it often takes some time until the text shows up. It's like typing and 5 seconds later you can see the machine work by putting letter after letter on the screen.
    Does anyone have an idea what the problem is?
    Could it be a hardware issue? Grafic-card?
    Any solutions?
    Would be nice hearing from you.
    Pero

    Found something... read, that it could be a mouse-usb problem when connected to the keyboard... so what I did was connecting the mouse directly to the mac... and ahhh first improvement... mouse-experienceis much better now... and I think, for what I can tell at this moment, finder operations seem better too.
    Never would have guessed that. I take my mini to the office every day where I have a second set of mouse and keyboard... had the same probs there... so probably it is a mac-usb-keyboard with attached mouse - problem.

  • MacBook Pro keyboard/mouse events delayed on Bluetooth

    I have a late-2008 MacBook Pro (the original Unibody).
    Sometimes my Apple Wireless Keyboard (latest model) ends up delaying its various key events; I'll press a key and it'll take a little while to respond, or sometimes the release gets delayed causing a long series of repeats (sometimes a few seconds' worth).  This is very annoying, and it comes and goes seemingly at random.
    I know a lot of other people have had this issue but there don't seem to be any open threads for it right now.  There are only two answers I've found: installing a firmware update (but that firmware is for the wired keyboard, not the wireless one), or disabling key repeat (which I actually, you know, use).
    I've also noticed similar delay/lag issues with the Magic Trackpad, so it makes me think that the problem is with the MacBook Pro itself.  I haven't noticed this happening on the bulit-in keyboard or touchpad.
    Anyone have any ideas?

    fluffy wrote:
    "Share my Internet connection" wasn't checked. Also I forgot to mention but I've set the devices up multiple times, with no change in behavior.
    It looks like all the "solutions" out there (change the batteries, zap the PRAM, etc.) are more just cargo-cult thinking that doesn't have much to do with the underlying problem, it's just that with such a low-repeatability issue that only comes up sporadically, of course rebooting your computer or zapping the PRAM will make the problem "temporarily go away" (just as waiting around and doing nothing will).
    I/we have no way of knowing what you have tried, so I/we go through troubleshooting steps. Apparently there is no clear-cut solution for your issue. The only other question I have is if there are other devices within 50' or so of your MBP which might operate on the same frequency and be causing interference.

  • Mouse event not working on JTable in JAVA 1.4.2

    mouse event is not recognised on empty table when using with java 1.4.2. Please specify if there is any chnge done for mouse event capture for table from java 1.3.1 to java 1.4.2.
    since mouse events are working fine for JTableHeader.
    if anybody have an idea please let me know.

    Hi
    JTable is there on JPanel . same code is working in JAVA 1.3.1
    actually its a bug in java 1.4.2 ( ref. bug_id=4940522 )
    here is the code reference..
    public class TableEditor extends JPanel
    �implements ListSelectionListener, Selector, Editor
    private JTable�myTable;
    private JPopupMenu myPopup;
    private Vector�myActions;
    private Vector�myListeners;

    public TableEditor(String anAssociation, Editor anEditor, int type)
    super(new GridLayout(1,1));

    myListeners = new Vector();
    myActions�= new Vector();
    myPopup�= new JPopupMenu();
    myTable�= new JTable();
    ��
    myTable.getSelectionModel().addListSelectionListener(this);
    myTable.addMouseListener(new MouseAdapter() {
    �public void mouseClicked(MouseEvent me)
    �{
    � if ((me.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
    � {
    ��// Update actions in case ListSelectionModel are out of sync.
    ��for (int i = 0; i < myActions.size(); i++)
    ��{
    Object o = myActions.elementAt(i);
    if (o instanceof SelectorAction)
    ((SelectorAction)o).check();
    ���}
    myPopup.show(myTable, me.getX(), me.getY());
    �}
    // Added mouse listener to JTableHeader
    // This is a temporary solution to open popup menu on blank table,
    // as in Java 1.4.2 no mouse event captured on blank table.
    // So for now we will capture the event from the table header.
    JTableHeader myTableHeader = myTable.getTableHeader();
    myTableHeader.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent me)
    �{
    if ((me.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
    // Update actions in case ListSelectionModel are out of sync.
    for (int i = 0; i < myActions.size(); i++)
    ��{
    Object o = myActions.elementAt(i);
    if (o instanceof SelectorAction)
    ((SelectorAction)o).check();
    ���}
    myPopup.show(me.getComponent(), me.getX(), me.getY());
    � }
    �});
    The solution given is temporary ( adding JTableHeader component)..
    we want to retain the same functionality .. mouse event should get captured on empty table only..

  • Mac java - no mouse event

    I am having trouble with my app where when you are at the login screen and you enter your login name, then click on the password text field the focus will not go there but remains on the user name field. You can tab ok to the password field. Has anyone encountered this with mac's. I am not sure if it's the code ( I have taken it over from someone else).
    At one point the tab didn't work either, but I found some code that was specific to 1.4 and newer versions of Java, but it was only looking for Sun's 1.4 or better, not Apple's, so I was able to fix that by checking to see if the Java being used was Apple's. So I'm not sure if this is another code-specific exclusion, but if it is, I just can't find it. The mouse click works fine if I use Apple's 1.3 java.
    So I guess my question is, does anyone know of any issues with mouse events and Apple's java 1.4 version.
    Thanks.

    Something isn't right with your code. The code below works fine on OSX 10.3.2:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SignInDialog extends JDialog {
       private JTextField serverJTextField = new JTextField("server");
       private JTextField userNameJTextField = new JTextField("username");
       private JPasswordField passwordField = new JPasswordField("password");
       public static void main(String args[]) {
          new SignInDialog();
       public SignInDialog() {
          super();
          try {
             init();
             setVisible(true);
          } catch (Exception ex) {
             ex.printStackTrace();
       private void init() {
          this.setTitle("Login");
          this.setResizable(false);
          this.setSize(new Dimension(270, 187));
          this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
          JLabel serverJLabel = new JLabel("Server:");
          JLabel usernameJLabel = new JLabel("Username:");
          JLabel passwordJLabel = new JLabel("Password:");
          JButton loginJButton = new JButton("Login");
          JButton cancelJButton = new JButton("Cancel");
          // (int x, int y, int width, int height) 
          serverJLabel.setBounds(new Rectangle(10, 12, 130, 25));
          serverJTextField.setBounds(new Rectangle(84, 12, 167, 25));
          usernameJLabel.setBounds(new Rectangle(10, 49, 130, 25));
          userNameJTextField.setBounds(new Rectangle(84, 49, 167, 25));
          passwordJLabel.setBounds(new Rectangle(10, 86, 130, 25));
          passwordField.setBounds(new Rectangle(84, 86, 167, 25));
          loginJButton.setBounds(new Rectangle(90, 123, 75, 25));
          cancelJButton.setBounds(new Rectangle(176, 123, 75, 25));
          this.getContentPane().setLayout(null);
          this.getContentPane().add(serverJLabel, null);
          this.getContentPane().add(serverJTextField, null);
          this.getContentPane().add(usernameJLabel, null);
          this.getContentPane().add(userNameJTextField, null);
          this.getContentPane().add(passwordJLabel, null);
          this.getContentPane().add(passwordField, null);
          this.getContentPane().add(loginJButton, null);
          this.getContentPane().add(cancelJButton, null);
          loginJButton.addActionListener(new java.awt.event.ActionListener() {
             public void actionPerformed(ActionEvent e) {
                System.out.println("loginJButton.actionPerformed");
          loginJButton.addKeyListener(new java.awt.event.KeyAdapter() {
               public void keyPressed(KeyEvent e) {
               if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                  System.out.println("loginJButton.keyPressed");
          cancelJButton.addActionListener(new java.awt.event.ActionListener() {
             public void actionPerformed(ActionEvent e) {
                dispose();
    [/code[                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • JPanels are not reading Mouse Events

    I created a basic Tic Tac Toe game, with individual "TicPanel"s inside a JPanel inside a JFrame object, however, none of the mouse events are working? Is it because the JFrame is receiving and doing nothing with the MouseEvents?
        private class TicPanel extends JPanel implements MouseListener
            private int owner; //-1 = none, 0 = O, 1 = X
            private Graphics g;
            private int num;
            ActionListener listener;
             * Constructor
            public TicPanel(int num)
                this.num = num;
                g = getGraphics();
                owner = -1;
            public void setX()
                owner = 1;
                g.drawLine(0,0,getWidth(),getHeight());
            public void setO()
                owner = 0;
                g.drawOval(0,0,getWidth(),getHeight());
            public int getOwner()
                return owner;
            public void mousePressed(MouseEvent evt){}
            public void mouseReleased(MouseEvent evt){}
            public void mouseExited(MouseEvent evt){}
            public void mouseEntered(MouseEvent evt){}
            public void mouseClicked(MouseEvent evt)
                System.out.println("works");
                listener.actionPerformed(new ActionEvent(this, num, ""));
                setX();
            public void addActionListener(ActionListener listener)
                this.listener = listener;
        }   Edited by: TheWhiteLynx on Aug 10, 2009 2:16 PM

    TheWhiteLynx wrote:
    I created a basic Tic Tac Toe game, with individual "TicPanel"s inside a JPanel inside a JFrame object, however, none of the mouse events are working? Is it because the JFrame is receiving and doing nothing with the MouseEvents?I don't see anywhere that you are adding a MouseListener to anything. Usually this is done with the addMouseListener(...) method.
    Oh, and please read the Sun graphics tutorial as this is not the way to do graphics in Swing. You do not want to get the Graphics object via getGraphics method but instead do your painting in a paintComponent override method and get your Graphics object from the parameter passed to this method. The tutorials will explain all.
    Edited by: Encephalopathic on Aug 10, 2009 2:29 PM

  • Can i capture the the mouse events

    i am writting application in which i have to send the screen image to client as well as mouse events and keyboard events. i am successfull in doing screen image but mouse events are not traped
    please send me any suggestion about how i will do it.
    [email protected]

    Have you tried to implement MouseListener?

  • Mouse events during Thread.sleep

    hi.
    I have an applet .
    I have a alghoritm simulator.
    Everytime I find a solution I call the method Thread.sleep .
    I want to pause the application and I create a JToggleButton Pause .
    When I press the Pause during sleep mouse event are managed at the end of alghoritm.
    How can I manage mouse events during sleep?

    All UI events (such as mouse events) occur on the event dispatch thread (EDT).
    That means if you sleep on the EDT, you lock up the UI. For this reason, you shouldn't be sleeping on the EDT.
    I'm not sure what your sleep is trying to do but you need to manage your threads a little more carefully. For instance, any time consuming process which is invoked as a result of a UI event needs to be fired on a new thread to prevent the UI freezing. The fun starts when you have to update the UI as a result of that process, because you should then hook back onto the EDT to avoid the risk of deadlock.
    Some utility classes are provided, such as SwingUtilities, and other example code is provided on Sun's site, such as SwingWorker - but if you do much UI work you'll probably end up with your own core set of threading tools and so on to make life easier.

  • Working with mouse events in Strobe's Widget classes

    I'm adding a caption on/off toggle button (classname CaptionButton) to the ControlBar class of Strobe Media Playback 1.5.1, and I'm having a difficult time understanding how mouse events are passed to child widgets of a ButtonWidget. In my CaptionButton class (which extends ButtonWidget), I add an instance of another widget, ListWidget, that extends Widget, and I show/hide this ListWidget with a mouse click event in the CaptionButton. The ListWidget is a composite class with a List component from Flash CS5, and the cell renderers in the List component do not respond to mouse events (over, selected, etc). How do I enable this type of mouse interaction within a Widget class? With the VolumeWidget, it looks like all mouse events are recreated and then controls are manually positioned according to the event properties, but this would be rather difficult with a component that has a virtual layout like List component. Any suggestions would be greatly appreciated.
    -Robert

    Ok, found that WidgetHint sets mouseChildren = false, etc. But I have a new problem---how do I stop autoHide timer while the user is interacting with a child widget? I was looking at the VolumeWidget that is used from the MuteButton widget, but I don't see how it stops the autoHide timer from enacting.

Maybe you are looking for