Selection via keyboard in JComboBox

Hi all,
I use a JComboBox with the followin items:
"New York", "Netherlands", "Nigeria"
When the JComboBox has the focus and the user starts typing <n> + <e> + <t> then "Netherlands" should be selected, whe he starts typing <n> + <e> + <w> then
"New York" should be selected an so on...
How can I do this or where can I find more information?
Best regards
Juergen

... I've found a solution:
I've written my own class which extends KeySelectionManager (see below).
Then use myJComboBox.setKeySelectionManager(new IncrementalKeySelManager ()); to set the KeySelectionManager for your JComboBox.
This works for JDK1.3.
Best regards
J�rgen
Stuttgart
Germany
class IncrementalKeySelManager implements JComboBox.KeySelectionManager {
     private long lastKeyPressTime = new Date().getTime();
     private StringBuffer searchString = new StringBuffer("");
     public int selectionForKey(char aKey, ComboBoxModel aModel) {
          try {
               long actKeyPressTime = new Date().getTime();
               if (lastKeyPressTime + 1000 < actKeyPressTime) {
                    searchString = new StringBuffer("");
               if (aKey >= 33
                    && aKey <= 127
                    || aKey == '�'
                    || aKey == '�'
                    || aKey == '�'
                    || aKey == '�'
                    || aKey == '�'
                    || aKey == '�') {
                    searchString = searchString.append(aKey);
               } else {
//                    System.out.println("aKey: " + aKey);
               lastKeyPressTime = actKeyPressTime;
               for (int i = 0; i < aModel.getSize(); i++) {
                    Object entry = aModel.getElementAt(i);
                    String listItem = entry.toString().toUpperCase();
//                    System.out.println(
//                         "testing '"
//                              + listItem
//                              + "' with '"
//                              + searchString.toString().toUpperCase()
//                              + "'; lastKey: "
//                              + (int) aKey);
                    if (listItem.startsWith(searchString.toString().toUpperCase())) {
                         return i;
               return -1;
          } catch (Exception ex) {
               return -1;
}

Similar Messages

  • How to clear the selected values in the JCombobox

    Hi All,
    Can you please tell - how to clear the selected values in the JCombobox
    I have four dropdowns in my application, When I click "CLEAR" button, what ever the values selected in the four drop downs should go off and view as "SELECT" in all the dropdowns.

    In addition to the above you should also check out [Combo Box Prompt|http://www.camick.com/java/blog.html?name=combo-box-prompt] which makes it easy to display the default prompt.

  • Windows 7 Keyboard locked after selecting Virual keyboard

    After selecting virutal keyboard display, keyboard no longer working on laptop or external keyboard.  Tried rebooting, removing battery, but the only the virtual keyboard works.  Can someone provide suggestion as to how I can resolve.  Fingers
    are getting very tired of pecking one key at a time.  The good news is that I was able to use my keyboard to key up this question.

    Hi vdemmaj,
    Have you tried the solution mentioned by S.Sengupta? 
    Please take the following steps for troubleshooting.
    1. Disable the on-screen keyboard and then check if the external keyboard could work.
    2. Contact the laptop manufacturer to see if there are some options to disable the external keyboard inputs.
    3. Check if the keyboard driver is the latest version.
    Hope it will be helpful.
    Best regards,
    Fangzhou CHEN

  • How do i select russian keyboard in firefox os 1.3 (zte open c)

    how do i select russian keyboard in firefox os 1.3 (zte open c)? i have no russian keyboard in list of 'built-in keyboards' and in list of 'more keyboards'.

    To give an update on this issue, here is the latest information I have:
    "Indeed the current eBay Open C doesn't come with root privilege. Now ZTE is going to put an engineering build on their website for users to download and flash."
    I will update this thread as I know more information. Thank you for your patience.
    - Ralph

  • Please HELP!! MacBook stuck on "Select your Keyboard" screen after installing Snow Leopard on a brand new hard drive!

    Hello, I just recently replaced my internal hard drive in my MacBook [from a 250gb to a blank/empty 750gb]. I managed to get OS X Snow Leopard installed with the DVD. Setup seems to run fine at first, I get the screen in space with the welcome message different languages while music plays. Then I'm asked to select my country, then here is my problem- the next screen asks me to "Select Your Keyboard", I select &amp; click "Continue" button, then my Mac is just showing the spinning beachball &amp; it stayed that way all night =( I don't know how to fix this. Anyone experience this or have any solutions for me? I'd appreciate any help! Thank you! [I've been googling since yesterday with no luck on finding an answer].

    It's diagnostic software. It's supposed to help you find problems. I don't think anyone is making any software yet that fixes hardware problems.
    That said, the two comments:
    Le husky wrote:
    Macbook pro freezes for no reason even after installing 10.8 on a brand new hard drive....
    .....also my trackpad is behaving very erraticaly sometimes, it's like it is possessed by a ghost....
    would lead me to think it's the logic board. On older MacBook Pro's both the USB I/O ports and the keyboard/trackpad are fed out of an integrated USB controller integrated into the South Bridge I/O controller. On newer models, the USB ports come out of an integrated North/South bridge controller and the keyboard/trackpad are handled by an SMC controller, which itself interfaces with the I/O controller. All of these items are on the logic board, and they're all unrepairable.
    ...unless of course the "internal drive [that] is installed in a cheap external case" is itself causing the problems. Another thing to try might be a different USB port, if you haven't done so already.
    I didn't know the price for Scannerz went up. I could have sworn I only paid 30-some bucks for it. Maybe it was on sale at the time. I don't remember.
    In any case, good luck.

  • Status clsd not unique (Selection via input help (F4) only) -COOIS

    Hi all,
    We doing upgradation 4.7E to Ecc 6.O
    In coois , When we enter system status as 'clsd' , system showing error msg
    Status clsd not unique (Selection via input help (F4) only)
    Message no. COIS054
    Why this error occurs.. how to solve this???
    looking for answers..
    Thanks in advance..

    Please read OSS note 1377678.

  • Stuck on select a keyboard screen

    I just reinstalled snow leopard on my macbook because the HD was having issues. I restarted it and it got stuck on the select a keyboard screen. I tried using fsck -f in single user mode and there are no known issues with the HD.  I also tried to create a new admin account by using /sbin/mount -uaw and then rm /var/db/ .applesetupdone in single user mode. None of this has worked. Any ideas?

    Well, this was a strange one. After paying another visit to the Genius bar, it was discovered my replacement hard drive was in fact the problem - the Mac simply couldn't see it. (The technician confirmed that none of them had ever encountered such an issue.) So with yet another new hard drive, the link above worked. Ie, first format the drive, then the restore will be able to 'see' the destination.

  • F-28 No account specified, items selected via document no. or reference

    Hi Experts,
    Good day! We would like to ask again your help regarding F.28. We tried to post in the said transaction but when we didn't indicated any account, message "No account specified, items selected via document no. or reference" appeared. But when we press enter, only "Document Number" and "Reference" in the choices and "Sales Order" is missing.
    May we know how we can add Sales Document/Order in the choices?
    Your response or expert advise will be greatly appreciated. Thank you and have a nice day.

    Hi:
          For the sake of recording incoming collection in F-28 with reference to Sale order number i have an idea. Instead of enter sale order(which is not possible except using FI_HEADER_SUB_1300)  in front end screen of F-28 why not to enter it at line item level. You can make this field enabled and ready for data entry in F-28 by making it required in field status of posting key that is used in F-28 (15) in OB41....Select posting key....additional account assignment...sale order make it require. Hope ti will help you.
    Regards

  • Is it possible to control the cursor of a XY-graph via Keyboard and read the y value of the curser x-position?

    I have following problem when I control the cursor via an attribute note, it is neccersary to free the cursor, but then it is not possible to read the y-Value of the cursor position. I want to control the cursor via keyboard and buttons, but with the funtionality of attribute setting "cursor fixed to plot".

    You know the X position so just read the Y value by reading it straight from the Y array instead of from a property node...
    Alternatively unlock the cursor if the position control has changed...and lock it again if it is constant for n milliseconds; to produce the Y value from the Y property.
    MTO

  • Summoning xfce4 panel plugin via keyboard.

    I am a xfce4 user. And I like this desktop system, but I can't summon the panel plugins, in particular the clipboard one, via keyboard.
    Does someone know how to?
    Thanks

    xo3e wrote:I tried to remove and add the xfce4-xkb-plugin (as SoK0LiK suggested), I even reinstalled it, but it helped just for one XFce session, then it went wrong again. However, I doubt it is the plugin's fault.
    As I suspected - neither it survived a session on my machine.
    xo3e wrote:The problem occured after i updated glibc (2.7-4 -> 2.7-5) and xorg-server (1.4-4 -> 1.4-5).
    Thanks for great hint! I did an upgrade of glibc as well, just could not remember it :-) Now we can suspect locale settings is somehow messed in newest glibc and newest xserver can't handle it. I'll try to find some info about it when I come back since right now I've gotta go.
    xo3e wrote:I'm experiencing very similar problem: the panel plugin refuses to show a flag (or even a name) for my alternate keyboard layout and displays "(null)" instead. My "alts_toggle" bothers me as well, as it switches from "us" to "cz" properly, but returns to default after pressing just one ALT key.
    I use this settings:
    Section "InputDevice"
    Identifier "Keyboard[0]"
    Driver "kbd"
    Option "Protocol" "Standard"
    Option "XkbLayout" "us,cz"
    Option "XkbModel" "pc104"
    Option "XkbOptions" "grp:alt_caps_toggle,grp:switch,grp_led:scroll"
    Option "XkbRules" "xorg"
    EndSection
    and toggling/switching works fine (i.e. it does not act weird in any way). Just the xfce-xkb-plugin shows (null) instead of Czech flag (or name) and won't remember per-window settings.
    There is already a bugreport in flyspray but it's been closed for some reason. I've requestet reopening.
    m.

  • Select a Folder/File starting with a Space via Keyboard

    I have just upgraded to Snow Leopard and I am having problems selecting a folder/file that starts with a space in the finder and in open/save. The problem is that it activates QuickView. In Leopard (10.5) you could override QuickView (in the Finder) by pressing the Option Key and the space bar at the same time and then pressing the next letter in the folder name. This action now open QuickView in Fullscreen mode. I have tried other key combos without success.
    Thanks for any help.
    Rich

    I have tried other key combos without success.
    OS X Help has this to say about that:
    -=-=-=-
    Creating keyboard shortcuts for applications
    You can assign your own keyboard shortcuts to menu commands in any Mac OS X application or in the Finder. This may be useful if, for example, one of the “global” shortcuts, which works the same in most applications, is used by one application for a different purpose. In this case, you can assign it a different key combination.
    You can create keyboard shortcuts only for existing menu commands. You can’t define keyboard shortcuts for general purpose tasks such as opening an application or switching between applications.
    To create a keyboard shortcut for an application:
    Choose Apple menu > System Preferences, and then click Keyboard.
    Click Keyboard Shortcuts, and then click the Add button.
    Choose an application from the Application pop-up menu. If you want to set the same key combination for a menu command that appears in many applications, choose All Applications.
    If the application you want to select does not appear in the list, choose Other and locate the application using the Open dialog. Some applications may not allow you to set keyboard shortcuts.
    Type the menu command for which you want to set a keyboard shortcut in the Menu Title field.
    You must type the command exactly as it appears in the application menu, including ellipses and any other punctuation. An ellipsis is a special character that looks like three periods. To type an ellipsis, press Option-semicolon, or use the Character Viewer. It may be difficult to know whether the command is written in the menu with a real ellipsis or with three periods, so if one does not work, try the other.
    Click in the Keyboard Shortcut field and press the key combination that you want to assign to the menu command, and then click Add.
    You cannot use each type of key (for example, a letter key) more than once in a key combination.
    Quit the application for which you added or changed a keyboard shortcut.
    Restart the application to see the keyboard shortcut in the application’s menu.
    If you assign a keyboard shortcut that already exists for another command or another application, your new shortcut won’t work. Find the menu command that’s using it and reassign the keyboard shortcut for that item.
    To remove a customized shortcut, click the Delete (–) button.

  • R11i - Can tab pages be selected via the keyboard?

    On a form with multiple tab pages, is there a way to select a specific tab page using only the keyboard?
    I see that F2 will pop a small window listing the tab pages, but you still need the mouse to select one.
    And I don't want to press the TAB key thru all of the fields on a tab page to get to the next.
    Any ideas?
    Thanks!
    null

    Hello,
    Shan Pin Koh is correct...you can change the color of a Tab Control (from the "Array and Cluster" subpalette) with your paintbrush tool. There is currently no way to assign different colors to different pages, but this is a feature that will be available in the next release of LabVIEW.
    I hope this answer sheds some light on the situation for you. Have a pleasant day.
    Sincerely,
    Darren Nattinger
    Applications Engineer
    National Instruments
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Why values selected for a h:selectOneMenu via keyboard are not accepted?

    Hi,
    I have a h:selectOneMenu in a jspx page. When i run the page on IE6 and I select a value using the keyboard, the value selected is not accepted. But when i run the same page on Mozilla Firefoz 1.5 and select a value through the keyboard it works..
    Can someone help me on how to get the value wen i select through the keyboard on IE6.
    Thanks
    Meenackshi

    Tell IE to use the Sun VM.

  • Selecting Logic tracks via Keyboard

    I want to use Logic live, my idea is to set up (for example) 20 different virtual instruments on 20 respecive tracks. is there a way fro my CME UF8 to simply scroll down or select any of those tracks to play the sound required?
    really just wanna use my Macbook pro live as a sound module, any ideas?
    cheers

    I have been doing this live for about a year...My live template has 127 tracks
    each one wired to a single cable switcher reading patch changes (I can't actually run 127 VIs or even half that however. I am sadly limited to a 1.67G PBG4 with
    2G RAM since most of the softsynths I use are 3rd party AUs which are not Universal). If the UF8 has a keypad for patch changes, this a good way to go, since you get surefire random access to your sounds.
    I should add that I use this to supplement a rompler, not replace one. It is not
    reliable enough to stand on its own, and the meter is in the red before I can
    get enough sounds and softsynths going to replace a modern workstation. But hopefully, the Intel changes that for the better...time will tell.
    best JF

  • Font Selection in Keyboard Viewer

    In previous versions of the OS the Keyboard Viewer let me choose what font I wanted to view. Now all I see are "Standard" and a few odd fonts. Am I missing some preference setting that will allow me to view ANY font? I have, for instance, Koch Signs which I can't view at all any more.

    Tom Gewecke wrote:
    for most special characters you must use the Character Palette and not the keyboard for input. The Favorites section of that is designed to provide easier access to special characters that are frequently used. Or a custom keyboard layout can sometimes easily be created to include characters you need all the time.
    If you tell us exactly which ones you need, we can probably tell you whether and how a keyboard combo can be used.
    In my workflow, the special characters I need to use generally do have a keyboard combination to activate them -- my frustration is over the seemingly increasing hassle it requires to see what that key combination is. And the difficulty with setting "Favorites" is that there aren't really any specific ones I frequently need on a regular basis.
    Here's a typical example: I was recently using the Hoefler Text font to generate captions and special titles for some montages I was creating in Photoshop. Hoefler has an "Ornaments" style, which had some decorative glyphs I wanted to use to bookend some of the text entries. Using Font Book (with Preview set to Repertoire) I could easily see all the available glyphs in that Ornaments style, at whatever size I wanted to view them.
    So far so good. And each of these characters had its own keyboard combination. The trouble is, Font Book (unless I'm missing something) won't tell me what that keyboard combination is for any given character. And Keyboard Viewer now won't let me select the font and at least see to which keys (and with which modifiers) all of the characters for that font have been mapped. (In fact, Keyboard Viewer should automatically open with whatever font you're currently using already selected.)
    So I end up having to run my finger along every key in every row, and then do the same with Shift, Option, and Shift-Option held down, just to figure out which key combo generates the little left-facing squiggly thing in this particular font.
    With Character Palette (which I've re-discovered thanks to this and other threads), I can at least use the Insert option to pop a selected character into whatever file I was working on -- but how do I first try out a special "string" of these characters to see how they'll look together? I seem to recall the old Key Caps utility would let you do that.
    I guess my main point is that all of these kinds of functions and options need to be integrated into Font Book in an easy-to-use way.
    PS The best place to tell Apple how you feel about this issue is here:
    http://www.apple.com/feedback/macosx.html
    Believe me, I have. For many, many apps. Many, many times.
    I sometimes wonder how seriously the Feedback is actually monitored, however, since very often the options offered in the questions you need to fill out (what version of the app are you currently using; which version of the OS; etc.) are several months out of date. One can only hope that even though the pages themselves are not being actively maintained, at least some of the user input sent via those pages does get looked at.
    (And while Apple would never say this publicly, IMHO if they're smart they've also got a staff of people whose only job is to monitor the Apple Discussions Forums, and track what's working and what's causing frustrations in the OS, its hardware, and all of the apps.)
    In any case, thanks Tom for the reply and the offer of assistance.
    John Bertram
    Toronto

Maybe you are looking for

  • Error message and bbm failure.

    Blackberry Curve 8520, OS5, carrier Orange. Three problems: 1.  When I turn on the phone I get an error message: "You are attemptin g to open a secure connection but the senders certificate is not trusted" Options are "Continue", "Close connection",

  • My phone won;' turn back on

    help please my phone has turned off and wont turn back on.. have not dropped it r anything dont know what to do. the apple logo comes up and off when plugged in but wont turn on

  • Net Profit difference in B.Area

    hi experts, There is a difference in the net profit reflected in the Financial Statement s_alr_87012284 of the B.Area ILSS: Net Profit as per Shareholder's Fund:     Rs 40062507.87/- Net Profit as per Calculated Profit/Loss: Rs 37552116.32/- Differen

  • Can't open Bridge CC.

    Just got subscrition today and it worked.  Cloosed it and I cannot open it again.

  • Everytime I try to download a song from Itunes, an error comes up.

    Ok here's the thing... I brought three songs off of Itunes, and everytime I try to download them, it says: Their was an error while downloading, the network connection timed out. I'm new to this hole Ipod thing, and have no idea what to do. Please he