Making the Tab key not work in the JTextArea

In my view I have a JTextArea along with a bunch of JTextFields and JComboBoxes. The user is usually going to tab out of a field in order to go to the next field. What's happening is when the user tries to tab out of the JTextArea, the cursor just moves by a tab length within the JTextArea instead of going to the next field. And if the JextArea has some text in it and if the user tabs into the JTextArea, the whole text gets selected and on hitting the next tab, it gets wiped out.
I am trying to make the JTextArea not respond to the tab by writing the following code. Keymap keyMap = JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP);
KeyStroke tabKey = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0, false);
keyMap.removeKeyStrokeBinding(tabKey);
jTextArea1.setKeymap(keyMap);But it's still not working. Can anybody tell what's wrong with that code. Or is there any other way to do it? Any help/hints appreciated.
Thanks.

>
If you're using jdk1.4, those other solutions won't
work because the focus subsystem has changed radically
(see
http://java.sun.com/j2se/1.4/docs/api/java/awt/doc-file
/FocusSpec.html). The upshot is that you have to
specifically register the keystrokes that you want to
use for focus traversal. In your case, you have to
re-register the Tab and Shift-Tab keys, and
they don't seem to have provided a simple way to do
that. Here's what I come up with:Set forwardTraversalKeys = new TreeSet();
forwardTraversalKeys.add(KeyStroke.getKeyStroke(
KeyEvent.VK_TAB));
forwardTraversalKeys.add(KeyStroke.getKeyStroke(
KeyEvent.VK_TAB, InputEvent.CTRL_MASK));
textArea.setFocusTraversalKeys(
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
forwardTraversalKeys);
Set backwardTraversalKeys = new TreeSet();
backwardTraversalKeys.add(KeyStroke.getKeyStroke(
KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
backwardTraversalKeys.add(KeyStroke.getKeyStroke(
KeyEvent.VK_TAB, InputEvent.SHIFT_MASK |
K | InputEvent.CTRL_MASK));
textArea.setFocusTraversalKeys(
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
backwardTraversalKeys);Or, you can just press CTRL+TAB instead of TAB when
you get to the JTextArea :).=====================================
i used the above thing but i am getting exceptions classcast exception n method not found (forwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB));)keystroke.get keyStroke(int)???? where i am going wrong as it will be quite helpful for me am using jdk1.4.1_02
thnaks

Similar Messages

  • I can not use the tab key to move to the next field or use the shift and tab to move to the prior field in forms.

    After updating to 7.0.1 I can not always use the tab key to move to the next field or use the shift and tab to move to the prior field in forms. This always worked in previous versions and it's much needed for my type of work. Does anyone know of a setting to activate this? If not can the Firefox developers work on this issue (please). I love Firefox but desperately need this feature to work correctly. Thanks!

    I tried in safe mode and the tab key worked just fine. I'm not sure about all web forms I've only recently updated to 7.0. The wen form I was using was for appraisal purposes and it has multiple data fields to fill in and also drop down menus to select from. Might I always have to use Firefox in safe mode to be able to utilize the tab between field feature? Thanks for your help!

  • I cannot get the caps lock key or the tab key to work.  Could they be broken?

    I cannot get my caps lock key or the tab key to work.  This is a wired keyboard.  Could the keyboard be broken, or have I messed up some setting?

    Very possibly however you haven't completed a profile so we have no idea what version of OS X you use. First thing to do is complete your profile, if you don't know how  please click Profile Update.
    I am going to assume you are running ML, if so open System Preferences - Keyboard - uncheck the box that says  Use all F1, F2, etc. keys as standard function Keys.
    If that does not work then please reset the SMC and PRAM each 3x back to back.  You can find instructions by clicking Intel iMac SMC and PRAM resets

  • ALT+TAB key not working in Acrobat CC

    In PC, ALT+TAB key not working in Acrobat CC version...PLs. suggest your best ASAP

    How does this connect to the Acrobat SDK? Are you a programmer?

  • Adobe Staff Please Read - Tab Key Not Working in InDesign HTML5 based panel

    Tab Key Not Working in InDesign HTML5 based panel
    Instead of changing focus to next entry field when the tab key is pressed it hides the panel instead.
    UI Nightmare.

    I’m using editable text fields. When I hit tab nothing happens. Focus stays on current text field.
    Mike Baugh • Creative
    Director, Digital Production
    +1 240-662-4442 office
    +1 410-807-1633 mobile
    [email protected]<mailto:[email protected]>
    agency.discovery.com<http://agency.discovery.com/>

  • TS1381 The X key only works when the shift key is depressed

    The X key only works when the shift key is depressed.  can only type capital

    I have this same issue with the Letter L.  I can ony type it with a captiaL L.  The Lowercase L does not work in Safari, but works in other programs.
    This suggestion did not work for me.

  • I was running KeyPassFox with Firefox 8.0.1, but the plugin does not work in the new release (9) . Is there a way to restore my previous version with all of my bookmarks intact? I do not mind if I have to restore the plugins myself.

    I was running KeyPassFox with Firefox 8.0.1, but the plugin does not work in the new release (9) . Is there a way to restore my previous version with all of my bookmarks intact? I do not mind if I have to restore the plugins myself.
    The plugin shows on the list as enabled and functioning, yet the tool does not show on the toolbar. It would appear that I need to restore the previous version of Firefox and wait until a newer release of the plugin is available before upgrading the browser.

    I copied the iTunes file from the external drive and it's in both places.  I thought all I would need is the iTunes program (which I downloaded to new computer) and my iTunes library file.  There must be something else that's missing.  My iTunes library looks the same on the new computer as it does when I open it on the external drive.  If I click on an iTunes library song from my new computer, it will only play if I have the external drive plugged in.
    My back-up drive is a mess.  I have multiple copies of music, video, photo, and document files and I don't know how that happened. ={  Obviously, I don't know how to back up stuff properly and there are back-up files extending over a 6- to 8-year period.  I think all I did was just drag and drop the main folders from the back-up drive to the same main folders on the C: drive.  Also (and I'm kind of fuzzy on this) Windows used to automatically save music files in a folder within my document files (which makes no sense to me).  As my Jewish friends would say, "Oy Vey!" 

  • When I connect my ipod touch tomy computer it says that the device will not work because the Apple mobile device hasnt been activated?

    Why does a meesage pop up when I connect my iPod touch saying that the device will not work because the Apple mobile device hasn't been activated?          

    Refer to this article to restart AMDS:
    How to restart the Apple Mobile Device Service (AMDS) on Windows
    http://support.apple.com/kb/TS1567

  • I have Photoshop cs5 and the pen does not work. The icons below also do not work. Why? and how can I activate them? Thank you , Wren

    I have Photoshop cs5 and the pen does not work. The icons below also do not work. Why? and how can I activate them? Thank you , Wren

    Why?
    Do you expect an answer to that question based on the information you have provided so far?
    Please read these and proceed accordingly:
    http://blogs.adobe.com/crawlspace/2012/07/photoshop-basic-troubleshooting-steps-to-fix-mos t-issues.html
    http://forums.adobe.com/docs/DOC-2325

  • HT201406 I cant scroll my iphone or the touchscreen is not working and the invert color is on i wanted to off it i cant scroll it down  what will i do i need some help

    I cant scroll my iphone or the touchscreen is not working and the invert color is on i wanted to off it i cant scroll it down  what will i do i need some help

    Did you try recovery mode? iOS: Unable to update or restore
    Or How to put iPod touch / iPhone into DFU mode

  • My iPhone has been badly damaged and I cannot get the screen to work. I want to do a backup to transfer to my new phone but the backup will not work because the phone is locked. Can I input my lock code to the phone via the computer to allow a backup?

    My iPhone has been badly damaged and I cannot get the screen to work. I want to do a backup to transfer to my new phone but the backup will not work because the phone is locked. Can I input my lock code to the phone via the computer to allow a backup?

    Sorry, no.

  • My iphone4 freezes causing the battery to drain quickly, the buttons do not work while the phone is frozen. what can i do?

    My phone has started to freeze, when I pull the menu bar down, when I am in apps, just any time. when it freezes, the buttons do not work. The battery dies within an hour of being off the charger. I do not know what to do, or why it has started to do this. please help.

    Hello taylordoveriphone4,
    After reviewing your post, I have located an article that can help in this situation. It contains a number of troubleshooting steps and helpful advice concerning performance issues:
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/TS3281
    Resolution
    If a single application is not responding or stops responding when it opens, you can force it to close.
    If the device is unresponsive or if certain controls aren't working as expected, restart your device.
    If the device remains unresponsive or does not turn on (or power on), reset your device.
    If there is no video or if the screen remains black, verify that the device has enough charge to turn on:
    If you are using an iPad, ensure that it's connected to the USB Power Adapter supplied with the device.
    Let it charge for at least twenty minutes, then see if it starts normally.
    If there is no image on the screen, press the Sleep/Wake button to attempt to wake the device.
    If the screen displays a red battery icon, continue charging the device until the battery is fully charged. Learn more about charging iPhone and iPod touch, or iPad.
    If the above steps do not resolve the issue, or the if the screen remains black or shows a persistent Apple logo, try restoring with iTunes:
    Connect the device to your computer and open iTunes.
    If the device appears in iTunes, select and click Restore on the Summary pane. Learn more about restoring iOS software.
    If the device doesn't appear in iTunes, try to force the device into recovery mode, and then restore it.
    If the above steps do not resolve the issue, contact Apple.
    Thank you for contributing to Apple Support Communities.
    Cheers,
    BobbyD

  • Why is the tab functionality not working in Responsive layout? I need accessibility for non-mouse users.

    I have generated Responsive HTML5 output. The tab key does not do anything. I want users to be able to tab through the topics and expand or collapse the drop-down hotspots. Tab appears to do nothing. If I generate the same content in WebHelp output users can tab between topics and expand/collapse drop-down hotspots. Is there some sort of setting I have to select to get it to work in Responsive HTML5?

    Thanks Phil Flowers !
    Good tip !
    I' ll be ****.....it actually works too !
    This solves the issue of repetatively unplugging  and plug back in the wired USB keyboard to the TB display. 
    Now...if only the Apple support team would acknowledge the problem in the iMac community at large and step up with a hardware / software fix! 
    Love the TB display......but really...............a non funtioning USB keybord ( apple product )  ???  
    Maybe they missed the Computer Design & Engineering class that day.....or medicinal marijauna in the valley ? 
    The support from Apple on this issue reminds me of the 70's video game system ATARI.......The video game PONG comes to mind ....blip....blip....blip.....back and forth with the ball.......  And yet we were entertained & amused at the time !
    Oh well......they got my dollars too !   Just another unit sold !
    Cheers !

  • When a pdf file is opened in a tab, the automatic scroll function from the pad does not work in the other tabs, but only for the particular PDF tab.

    The scroll function from the pad/mouse does not work for the other tabs when a PDF file is opened.

    Hi NSHS,
    Have you checked to see if your PDF add-on is up to date? You should take a look at the [[Opening PDF files within Firefox]] Knowledge Base article. There is a lot of good information in there. You should try both of the suggested PDF add-ons to see if that fixes the issue.
    Hopefully this helps!

  • The multi-tabs is not working all the time. Windows7 Firefox 4.0.1 I have the correct opetions set for multi-tabs.

    The multi-tabs is not working. I have the correct options set for multi-tabs. But when I open Firefox and try to add a site from Bookmarks it uses the same tab that is opened.

    Right click a tab and you will get the option to bookmark all tabs. Or use keyboard '''Alt + B''' which opens the old style menu. You can make changes to Firefox, as explained in this post: [/questions/799856#answer-155765]

Maybe you are looking for

  • RFC Adapter Problem: Adapter Engine Field Blank

    Hi, I want to invoke a BAPI defined on a R/3 system. I am trying to create a RFC Adapter in the Integration Directory by creating a communication channel. The problem I am facing is that when I define the Adapter Type as RFC, the Adapter Engine dropd

  • JSPs writing binary data

    Hi, I'm trying to develop a JSP that returns binary data in the form of a jpeg image. I found this on google where one of the replies correctly states that to be compliant I need to use XML JSPs: http://www.caucho.com/quercus/faq/question.xtp?questio

  • KM Std Properties via API: can be done!

    Hi guys, This is to let you know that <b>std resource properties</b> (created by, created on, changed by, changed on, content length, ...) <b>can indeed be set using KM API's</b>. Maybe this is not great surprise to someone, but it is for me, that af

  • Idoc Error Handling through workflow

    Hi all,   I want to send the Error Notification for a particular person for whom the task orders is assigned in the organization chart. What all the things I need to do.   I have created the org chart and I have assigned the task to a user under a po

  • Where can I download Color Finesse and how I can install them with Premier Pro or After Affect ?

    I recently purchased master collection 5 DVD version. On DVD box I have three serial numbers: Master collection, Ppro/AE CS4 32 Bit and Color Finesse. I used Master collection serial to activate my product. I am having 64 bit os, so I did not use Ppr