473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Tracking key combination

How do I track a key combination like this '<abcd'?
I have trapped the '<' key using keypressed in a jtextpanes
keylistener. But what to do now? how do I trap the next lets say 3
charactes typed by the user?
Jul 17 '05 #1
1 3566
kr******@detandetfirma.dk (Kristian) wrote in message news:<c9**************************@posting.google. com>...
How do I track a key combination like this '<abcd'?
I have trapped the '<' key using keypressed in a jtextpanes
keylistener. But what to do now? how do I trap the next lets say 3
charactes typed by the user?


Create a char array, and store the characters in it using a counter which
indicates the next free index. To avoid having to resize or copy the
array, make the counter wrap around to the start of the array when it
exceeds the upper bounds: cnt=cnt%array.length; Then check the previous
n chars (remembering to wrap to the end if exceeding the lower bounds of
the array) for the required character sequence, where 'n' is the length
of the search string.

Suppose we are looking for the string ABCDE, and the user types xyABCDE:
(our array is the same size as the search string, which makes life easier)

----- Nothing typed.
^
xy--- User types xy, counter at [2].
^
xyABC User adds ABC, counter has wrapped to [0].
^
DEABC User adds DE, counter at [2]. Our required sequence is at
^ [2]-->[1] ( [2]-->[4], then [0]-->[1] ) which we can check
by looping [2]-->[6] while %'ing so 5 and 6 wrap to 0 and 1.

Modifying this scheme to check for different strings of varying sizes
requires a little bit more work, but not much.

-FISH- ><>
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: binger | last post by:
Okay, Superbowl is only a few days away, but I thought it would be cool to set up an online registration for a football squares pool. My thoughts are to have people go into anywhere on the 10x10...
1
by: Bo Xu | last post by:
Object of Combination By Bo Xu Introduction A combination of n things, taken s at a time, often referred as an s-combination out of n, is a way to select a subset of size s from a given set of...
3
by: Kyle Friesen via AccessMonster.com | last post by:
Mike, I have databse that creates a "tracking number" based on the selections made on the form via concatenating. At the end of the tracking number, I need a two digit (01-99) sequence number by...
2
by: Senthil | last post by:
Hi, The need is to read each line in a text file and based on the read data decision has to be taken whether to reposition the file pointer. The StreamReader.Position does not give current...
6
by: A.M-SG | last post by:
Hi, We are developing a SmartClient application and we are planning to expose business objects layer to SmartClient application by using ASP.NET SOAP web services.
6
by: depkefamily | last post by:
I have a large C++ program using multiple vendors DLLs which is giving me a major headache. Under release mode I get exceptions thrown from what looks like a dereferenced corrupt pointer. The...
1
by: bdockery | last post by:
So I figured out that if you use this html: http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&loc=en_US&InquiryNumber1=<TRACKING...
3
by: =?Utf-8?B?R3JhaGFt?= | last post by:
I've added 2 tracking services to the wf runtime; one is the standard SqlTrackingService: trackingService = new SqlTrackingService(<trackingConnectionString>); <workflow...
0
by: LiveTecs | last post by:
http://www.livetecs.com TimeLive Web Collaboration Suite is an integrated suite that allows you to manage project life cycle including tasks, issues, bugs, timesheet, expense, attendance. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.