摆动字母数字键盘 [英] Swing alphanumeric keypad

查看:41
本文介绍了摆动字母数字键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个键盘,它应该像手机键盘一样工作,想知道如何管理我们在单个键中的选择.例如,编号为 1 的键也有字母 ABC,在不到 x 秒内连续单击该键允许再次从 1 变为 A 到 B 到 C 再到 1,如果超过 x 秒,我们将回到初始状态数字 1.我想有一个计时器的用途,但我真的不知道如何使用它.感谢您的建议和指导.

I'm doing a keypad, that should work like a mobile phone keypad, and wondering how to manage the choice we have in a single key. For exemple the key with number 1 has also letters ABC, and continuously clicking the key within less than x seconds permits to change from 1 to A to B to C to 1 again and if we are over x seconds we are back to initial state with the number 1. I guess there is a use of timer but I don't really see how to make use of it. Thanks for advice and guidelines.

推荐答案

不,你不需要计时器.

在键的动作侦听器中,您要做的第一件事是获取当前时间.

In the action listener for the key, the first thing you do is get the current time.

您将当前时间与上次按下该键的时间(上次)进行比较.

You compare the current time with the time that the key was last pressed (previous time).

如果时间差小于x秒,将key的值从1移到A,A到B,B到C,或者C到1.

if the time difference is less than x seconds, shift the value of the key from 1 to A, A to B, B to C, or C to 1.

如果时间差超过x秒,设置key的值为1.

If the time difference is more than x seconds, set the value of the key to 1.

不知何故,您必须确定实际将字符发送到显示器的按键类型.

Somehow, you have to determine what type of key press actually sends the character to the display.

处理后,将当前时间保存为上次.

After processing, save the current time as the previous time.

这篇关于摆动字母数字键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆