Problem with disabling "ENTER" key in JTextArea

Hi,
I have the following codes to disable the 'ENTER' key in the JTextArea,
but it does not work. Does anyone know why?
KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
textarea.getKeymap().removeKeyStrokeBinding(enterKey);
textarea.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
// do something
Thanks,
Pin

I don't know how you mean "disable", but if you are going to ignore the Enter key, then add a KeyListener to the text area, and in the key pressed method, consume() the key event if the VK_ENTER was pressed. That's all, and you don't have to deal with that key binding thingy.
The other two event types (typed and released) might be ignored, the enter is processed during key press (as it is now, with the default settings).
The reason is that processing the Enter key (and other such internally understood keys) is done by the peer, but the peer won't get the key event if it's already consumed.
FYI: Were it a JTextField, consuming the Enter key presses would mean that the field won't fire action events any more. Since text area does not fire action events, therefore it's a non issue.
FYI2: Consuming the event only blocks the event to be sent to the peer, all the other listeners still get it.

Similar Messages

  • Problem with the enter key

    I am facing a problem when I press enter key on any control like buttons, menus etc., The event get transferred to the parent container. It results in very weird behavior.
    For example I am showing a right click popup on a button, and when I hit enter on the selected popup menu the parent button also get clicked.
    I am using jre 1.4.1, has any one experienced this.
    Does any one know the workaround ?
    Thanks
    - Bharat

    How to consume? Action even does not have this method.
    Also, I am looking for a generic solutions, my application is huge, even if the workaround suggested by works, I need to do it at lots of places.

  • How can i disable the Enter key in JTextArea?

    How can i disable the Enter key in JTextArea?
    When i press Enter key in JTextArea,I hope JTextArea do nothing.
    Thanks!

    HI, I've the same problem;
    uncle_alice solution works fine, but if I paste in textArea a multi-line text,
    this last results on more lines (rows);
    Isn't possible to avoid this?
    Alternatively, how can I disable cut/copy/paste on TextArea?
    Thank you in advance.
    MargNat
    Message was edited by:
    MargNat

  • Problem with the volume keys on my keyboard.

    Hey everybody,
    I have a problem with the volume keys on my keyboard. This started a couple days ago and I can't seem to figure out how to fix it. When I press the volume up or down buttons, the graphic appears on the screen as it normally would, but has no effect on the volume of the sound coming out of my speakers.  Therefore, the only way to change the volume of music or whatever I am listening to is to use the volume control within the program/website itself (itunes, youtube, etc.) Even changing the volume on the volume icon at the menu bar on top of the screen does nothing.  If anyone has an idea of how to go about solving this issue, I would greatly appreciate it. Thanks!

    First look into the Preference > Sound > Outpur whether internal Speakers are choosen.
    The only Preference to delete I can discover is com.apple.systempreferences.plist in your home Library folder. You can try to move it out to the desktop for example, not to loose all your settings. Restart and see whether the problem still persists. If you don't know how to do this here some Terminal (Applications > Utilities) commands. Enter them by copy and paste followed by <enter>
    mv ~/Library/Preferences/com.apple.systempreferences.plist ~/Desktop/
    restart
    to get it back:
    mv ~/Desktop/com.apple.systempreferences.plist  ~/Library/Preferences/
    confirm with "y" if you are asked to replace this file.
    marek

  • [svn:fx-trunk] 8277: Use blendMode="normal" to fix problems with disabled appearance when baseColor is set.

    Revision: 8277
    Author:   [email protected]
    Date:     2009-06-25 17:46:00 -0700 (Thu, 25 Jun 2009)
    Log Message:
    Use blendMode="normal" to fix problems with disabled appearance when baseColor is set.
    Bugs: SDK-19745, SDK-19762
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-19745
        http://bugs.adobe.com/jira/browse/SDK-19762
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/skins/spark/PanelSkin.mxml
        flex/sdk/trunk/frameworks/projects/spark/src/spark/skins/spark/TextAreaSkin.mxml
        flex/sdk/trunk/frameworks/projects/spark/src/spark/skins/spark/TextInputSkin.mxml

    This bug figures out also when creating a custom spark ComboBox, then trying to programatically update the userProposedSelectedIndex property. The proposed selected index is selected, but does not apply the same skin as when mouse is on rollover or item is selected due to up and down keys.
    The issue seems like updating the status of the item renderer to rollover or selected to get the same skin applied.
    Please could you attach DropDow nList.as that you edited ?
    Thank you so much.

  • I have a new hard drive and itunes and my computer (windows XP) no longer recognise my ipod. I also had the problem with the registry keys not being present but this has now been fixed. However i can no longer link my ipod up with itunes.

    When I first tried itunes with my new hard drive there was the problem with the registry keys but something also flagged up about needing a signed driver. Is this anything to do with why Itunes and my computer no longer recognises when my ipod is linked up? Whatever i try under 'devices' my ipod is never available to sync up. If anyone can help I would be most grateful.

    Thanks for your reply. Unfortunately this has not worked. I didn't have quicktime to begin with so I don't know if that makes a difference? After following the instructions, I get the "registry keys missing" problem appear again (which I've subsequently fixed again) and then when I connected the ipod I got the following message - 'Device driver software was not successfully installed'.
    I've tried windows update but this doesn't do anything as '...the service is not running'.
    Any suggestions?

  • I have a problem with disable my account in apple store

    hi i got a problem with disable my account apple store... so what should i do?

    You might be able to re-enable it via this page : http://appleid.apple.com, then 'reset your password'
    You might then need to log out of your account on your phone by tapping on your id in Settings > iTunes & App Store and then log back in so as to 'refresh' the account on it.
    If that doesn't fix it then you might need to contact iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • Problem with Sting Primary Key

    I have probleme with Sting Primary Key
    when i create new row
    System.out.println("is new:" + acct.getEntityState());
    show 1 - this row is not new
    why?

    Hi,
    I was unable to reproduce this behavior on OWM 10.1.0.8. It appears that you have a SR open for this issue, so I would suggest to continue with that process.
    Regards,
    Ben

  • Problem with push email key and adding mailbox

    There seems to be a strange problem with the email key. I added my gmail account initially but then i deleted it. I don't see any mailbox in the email setup, but i still receive notification on recieving a new email. But when I press the push email key on the home screen to open my inbox, it takes me to the email setup. I tried adding a mailbox, but when i select "add mailbox" the screen becomes whitish and nothing happens.
    I need to add my gmail account again. Please help me with this. Thanks!

    1. Predictive text can only be enabled in alphanumeric keypad, but from testing the QuickOffice 6 on the 5800 (same app used for both phones), It cannot use predictive text. Its not in the typing options. Furthermore, if you would be using the qwerty keyboard on the mini, predictive text AFAIK cannot be used.
    2. If using "vodaphone live" is giving an error in ALL applications, then it is not the fault of your phone but of the "vodaphone live" settings not being compatible to your phone. I assumed that it was only for email that it did not work. A similar case was one on T-mobile, wherein the T-mobile GPRS settings were incorrect which leads to the same issue as you do. The fix was to configure GPRS settings manually. You can also take it to vodaphone for them to configure it themselves.
    3. As I said, unless we find out what is different from the files that can play and cannot I cannot help you. Its not like I can check the files themselves. You can try attaching two each of the working files and non working files here for some of us to test on our phones.
    If you find my post helpful please click the green star on the left under the avatar. Thanks.

  • Keyboard problem with T410 - Control Key

    I have a problem with the control keys on the keyboard of T410.
    I swapped my X200 keyboard over to T410 to check if it is software or hardware issues.  With the X200 keyboard, the 'Ctrl' key is not working.  With the T410 keyboard, 'e', 'd', 'c' and 'Ctrl' keys are not working.

    Welcome to the forum!
    I believe that X200 and T410 keyboards are mapped differently in BIOS.
    Can you find another T410/T510 keyboard to test with?
    Cheers,
    George
    In daily use: R60F, R500F, T61, T410
    Collecting dust: T60
    Enjoying retirement: A31p, T42p,
    Non-ThinkPads: Panasonic CF-31 & CF-52, HP 8760W
    Starting Thursday, 08/14/2014 I'll be away from the forums until further notice. Please do NOT send private messages since I won't be able to read them. Thank you.

  • Bug: problems with the Escape key

    Hi all,
    In an attempt to get around real estate problems, I set my Dell 24" monitor in portrait mode. Logic 8 behaves as it should most of the time. However, there appears to be a problem with the Escape key. Most of the time, the Tools menu doesn't appear until you mouse out of the editing areas (eg into the menu area above the piano roll).
    Clearly, Logic should just take its resolution and screen dimensions from the OS but there appears to be a problem in extreme portrait mode.
    I'll report this but wanted to check that I'm not being an absolute and total plonker first. Anybody confirm this behaviour?
    Thanks!
    Pete

    that sounds like a memory issue. have you tried reorganizing memory?

  • Keyboard problems with the "z" key

    Hello everyone, I have problems with my "z" key.Recently, it is sufficent to touch the key without pressing to write the z.Unfortunately that happens also when I want to use the "t" or "u" next to it. I hope you can help me with this problem and can tell me what to do.Thanks in advance for your answers (and sorry for my bad english). greetings, bina90

    Try to reset the device by pressing hold of the home and power button for 15-20 seconds and letting of when the Apple logo appears.

  • Inputfield with Return/Enter key

    Hi,
    Could someone give me  hints about Inputfield with Return/Enter:
    In General I'd like to press the button after Entering a value in the Inputfiled, but it is also easy to handle with Return/Enter key.
    Therefor I want to have both possiblity(press Button or Return/Enter key).
    How can I here implement the 2. alternativ(Return/Enter key)? - with Javaskript or possible directly in HTMLB ?
    Thanks a lot in advance,
    Regards,
    Gauguin

    Hi,
    the label <InputField> has as agreggate submitOnEnter which triggers a server event when the cursor is in that field and you press <enter>.

  • How to disable "Enter" key - urgent

    - i have on my site one site password protected. Now i don't want that users cann use Enter key when they write password. Only when the click with mouse. For that i have onClick="..."
    How can i disable only enter key?
    Thanks

    Don't want the user to press the Enter key... who
    thinks up these ideas anyway? It never ceases to
    amaze me.Internet team in one of my early carrer companies were having problems with a search field on their web project... When the user pressed enter they were getting an error, but it worked when they clicked with the mouse.
    So they decided to remove the ability of the user to press enter, rather than figure out what was wrong and fix it... But they couldn't figure out how to disable the enter button either, so they just put red text below the search field asking users to click on the button and not to press enter...
    How the hell do some people get in the door in Software Companies?

  • Problem with Overwrite for Key Figures in ODS

    A bit of a long explanation, but the problem is not so complicated...
    We have an ODS containing contract line items.  Each line item has a key figure "Total Contract Target" that is marked with update type "overwrite".  We have modified the extractor that delivers data for this ODS so that the key figure is set to a value from the contract header.  Since we don't want the key figure to be duplicated if there are multiple line items on the contract, the user exit for the extractor modifies only the first line item delivered.
    For example, overall contract target value = 100.  Contract has 3 line items.  Contract target value for line item 1 is 100.  Target value for line item 2 and 3 is 0.
    This all works fine for initial loads, but there is a problem with the business content extractor for deltas.  Whenever a single change is made, it delivers three sets of  records.  Continuing the example, we would receive 9 records for the contract (3 sets of 3 line items).  Each of the three sets contains the same records.  Only the first set has the correct contract target value.  Since the ODS key figure is set to overwrite, our method of setting the total contract value in the first record doesn't work, because the extractor delivers duplicates so the duplicates overwrite the total with a 0.
    Would setting the key figure for total contract value to update type "additive" solve this? (I'm concerned that additions would be made if there were only a change to characteristics and not the key figure).  Thanks for your assistance.

    Since we ought to post solutions to problems we discover for people who search this forum...
    Solved this by modifying the customer exit for the extractor to set the key figure for the first contract line item encountered AND for all subsequent records with the same contract number / contract line item.  Since the key figure in the ODS is set to overwrite, this makes sure that the last record written doesn't overwrite the key figure with 0.

Maybe you are looking for

  • My macbook is sleeping all the time!

    About 2 weeks ago, my macbook instantly sleeped. From that day to now, my macbook could just not awake! do anyone knows how to fix it? or i have to buy another mac? Thanks, your answer is completely appreciated.

  • Using part of the 1TB TC Drive

    I want to get TC to backup to Mac computers. I don't, however, want TC to use the entire 1TB for just two computers. I want to manually backup certain files. Is it possible to set TC to only use a certain amount of the hard disk and then be able to c

  • Root creation problem through jndi api

    Hi all, i am using the following code to create the context. import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.naming.NameAlreadyBoundException; import javax.naming.directory.*; import

  • I'm constantly getting an error message - any ideas welcome

    I'm constantly getting an error message 'You are not connected to the internet - Safari can't open the page etc etc - but I know I'm connected - any ideas welcome -

  • Trouble seeing/using apps in EAS

    Hi Folks, I just did a first time install/configure of Essbase 9.3.1 on a Win2ks sp2 pc. Opening the EAS console, in Enterprise View I expected to see the 'Essbase Servers' directory pre-populated with at least one sample server and associated applic