protux-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Protux-devel] Java migration : Proof of concept for JMB


From: Luciano Domenico Giordana
Subject: [Protux-devel] Java migration : Proof of concept for JMB
Date: Wed, 14 Sep 2005 11:34:37 -0300

hi!
this applet is to demonstrate the low level keyboard event handling in java. It offers the minimum needs for a JMB porting.

Regards

import java.applet.Applet;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

/*
 * Created on Sep 13, 2005
 */

/**
 * @author ldomen
 */
public class Jmb extends Applet implements KeyListener
{

    private static long startTime = -1;
    private static long endTime =-1;
    private static int lastKeyCode =-1;

    public void init()
    {
        setSize(400, 400);
        setVisible(true);
        this.addKeyListener(this);
    }

    public void keyTyped(KeyEvent e)
    {
    }

    public void keyPressed(KeyEvent e)
    {
        int lkc = e.getKeyCode();
        if (lkc == lastKeyCode )
        {
            // do nothing ... Ignore autorepeat ...
        }
        else
            {
                startTime = e.getWhen();
                lastKeyCode = lkc;
                write("PRESSED event :" + e.getKeyChar() + " in "+startTime);
            }
    }

    public void keyReleased(KeyEvent e)
    {
        endTime = e.getWhen();
        lastKeyCode = -1;
        write("RELEASED event :" + e.getKeyChar() + "  DELAY=" + (endTime - startTime));
    }

    private void write(String s)
    {
        System.out.println(s);
    }

}


--
Luciano Domenico Giordana
Software Engineer / Java/C++ Senior Developer
IBM Brasil - Hortolândia - SP - +55 19 21327000 - R 5100
Project Protux : http://www.nongnu.org/protux

reply via email to

[Prev in Thread] Current Thread [Next in Thread]