BackSpace not working in textfield

Hi everybody!
I have a textfield that only lets enter numeric chars. It extends from JTextField.
The problem is that the Backspance key is not working. I see that is detected in the processKey Event but it does nothing.
I have seen some topics about that there is a bug in jdk1.3 and that a solution is using keyTyped instead. But I don't know how to do this.
May someone help me?
Thanxxxx

Hello,
i think the best way is to to use a custom PlainDocuments for your TextField:
import javax.swing.*;
import javax.swing.text.*;
public class NumberField extends JTextField {
     public NumberField(){
          setDocument(new PlainDocument(){
               public void insertString(int offset, String str, AttributeSet a)throws BadLocationException{
                    try{
                         Double.parseDouble(str);
                    }catch(NumberFormatException nfe){return;}
                    super.insertString(offset,str,a);
     public static void main(String[] args) {
          JFrame f=new JFrame();
          f.setBounds(0, 0, 100, 50);
          NumberField nf=new NumberField();
          f.getContentPane().add(nf);
          f.setVisible(true);
}Regards,
Tim

Similar Messages

  • Backspace not working

    On some of my systems, when I am in SQL*Plus, the backspace does not work. There must be a setting in the login environment, that affects this.
    How can I fix this in the profile, without having to type in something everytime I log in ?
    This is on Linux SLES9, running Oracle 10G.

    What is the result of stty on the Linux becoming?
    ($ is prompt, do not type $, type only stty)
    $ stty
    speed 9600 baud; line = 0;
    erase = ^H;
    -brkint -imaxbel
    or
    $ stty
    speed 9600 baud; line = 0;
    erase = ^?;
    -brkint -imaxbel
    If it was the latter, please try this.
    $ stty erase ^H
    If this made your SQL*Plus correctly,
    then please put it in login scripts on Linux for your convenience.
    (ex .profile, .bash_profile, .login etc.)

  • G,h and backspace not working

    hi,
    i am using hp notebook 2000 series past 5 month.
    suddenly switches "g","h" and backspace stopped working.
    My BIOS configue is : F.26 -02/21/2013(088A120000305910000620100)
    do let me know the correct solution.
    regards,
    chandresh.

    Hi,
    While this may well be a hardware issue, it's always worth trying the following.
    Open windows Control Panel, open Device Manager, expand Keyboards, right click on Standard PS/2 Keyboard and select Uninstall.
    When this has completed, shut down the notebook - if you're running Window 8/8.1, do this by holding down the left Shift key as you click on Shutdown to temporarily prevent a hybrid boot. 
    When done, unplug the AC Adapter and then remove the battery.  Hold down the Power button for 20 seconds.  Re-insert the battery and plug in the AC Adapter.
    Tap away at the esc key as you start the notebook to see if this will launch the Start-up Menu - if it does, select f10 to enter the bios menu.  Press f5 to load the defaults ( this is sometimes f9, but the menu at the bottom will show the correct key ), use the arrow keys to select 'Yes' and hit enter.  Press f10 to save the setting and again use the arrow keys to select 'Yes' and hit enter.
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • CTRL_ALT-BAckspace not working in KDE4 [SOLVED]

    Hi,
    I use KDE4 (not modded) and have noticed recently that CTRL-ALT-Backspace won't work.  I use it infrequently to jump to terminal mode so I'm not sure when this started.  Is there a setting somewhere for KDE4 or KDM that I can alter or is this an issue with X???
    Thanks
    Last edited by MillTek (2009-05-09 22:17:17)

    Have you enabled the functionality in x since the upgrade?
    http://wiki.archlinux.org/index.php/Xor … 27t_exit_X

  • Alpha property not working on TextField when publish for Reader 9

    Hi,
    I have a movie that is working fine when I publish for Reader 10, but when I publish for Reader 9, the code that assigns an alpha property to my TextFields stops working. I have a previous movie, which I probably did in CS4, that uses similar code to fade in and out TextFields. It was published for Reader 9 and works fine.Is it possible that something has changed in CS5 (note, I'm not using TLF text boxes, only dynamic TextFields)?
    Here's an example of the code I'm using:
    stop();
    import fl.transitions.Tween;
    import fl.transitions.TweenEvent;
    import fl.transitions.easing.*;
    import flash.events.*;
    import flash.text.*;
    import flash.text.TextFormat;
    import flash.utils.Timer;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    var txtFormat1:TextFormat = new TextFormat();
    txtFormat1.font = "Optima";
    txtFormat1.color = 0x000000;
    txtFormat1.bold = false;
    txtFormat1.size = 16;
    txtFormat1.leading = 2;
    var subtitle:TextField = new TextField();
    subtitle.autoSize = TextFieldAutoSize.CENTER;
    subtitle.selectable = false;
    subtitle.defaultTextFormat = txtFormat1;
    var fadeInSubtitle:Tween;
    addChild(subtitle);
    subtitle.x = stage.stageWidth / 2 - subtitle.width / 2;
    subtitle.y = stage.stageHeight / 2 - subtitle.height / 2;
    subtitle.alpha = 0;
    subtitle.text = "What is the most important question in";
    fadeInSubtitle = new Tween(subtitle,"alpha",None.easeNone,0,1,3,true);

    Thanks.
    Just curious: Is there a reason why the alpha on the TextFields worked without embedding fonts when publishing for Flash Player 10? Does it handle text, even when it's not TLF, differently than Flash Player 9?

  • Backspace not working on Mavericks (External USB Mac Keyboard A1243)

    After upgrading to Mavericks OS, my external keyboard's backspace key has stopped working. I have gone through my keyboard settings and unable to find any problems. The backspace works fine on another computer. Any ideas what the problem is?
    Thanks,
    Connor

    Hi williamsdesigns,
    Welcome to the Support Communities!
    The article below may be able to help you with this issue.
    Click on the link to see more details and screenshots. 
    One or more keys on the keyboard do not respond
    http://support.apple.com/kb/ts1381
    Cheers,
    - Judy

  • Backspace not working correctly

    While I'm in grid view I use Backspace to remove a series of selected photos from LR. I am given the option to Delete or Remove. When I choose Delete, the image is still left behind in the folder but is removed from LR, acting essentialy the same as "Remove".
    When I right click a single image I am given the same options and "Delete" works correctly removing from LR and moving the image into recycle.
    Is there a way to get Backspace to operate properly? I find it rather unweildy to have to delete one image at a time while reviewing them.
    I'm running Vista Business, LR 1.0 on an intel e5500 laptop with 2gigs of ram and 60gigs of free space on my HD.

    The Delete Remove only really works in Folders. In Collections and Keywords, it just removes the image from the Collection or Keyword list.
    So... Are uou in Folders or All Photographs when doing this?
    Don
    Don Ricklin, MacBook 1.83Ghz Duo 2 Core running 10.4.9 & Win XP, Pentax *ist D
    http://donricklin.blogspot.com/

  • Bug JDeveloper 10.1.3 : Backspace not working in .jspx source editing mode

    I checked the first 3 pages to see if someone else posted it and it don't look like it, so here I go.
    I just downloaded JDeveloper 10.1.3.0.4 and found out that backspace no longer work when editing a .jspx page in source mode but works fine in design mode. In EA it was working fine. Is that wanted? Or am I the only one with that issue?
    Regards

    Hmmm,
    I must have been too quick to install some plugins maybe. Time to retry with clean install I guess.
    Thank for the quick input.

  • Belkin keyboard case backspace not working

    hello i just got the iPad mini and a belkin keyboard case and the backspace will only work if I hold down ether alt or control keys after updating to the newest update what should I do to correct this?

    Contact Belkin, the makers of the keyboard case you are having problems with.

  • Backspace Not Working....iTunes misrepresenting Content

    Hi all, i docked my iPod on my new C2D iMac this eve, i started trying to delete stuff from my iPod and the Mac was throwing the move to trash or keep file menu, so out of instinct i was saying keep file. As a result the songs were being removed from the iPod library and not the iPod capacity. I can understand this in terms of OSX but not on a iPod, i then started to use the delete button instead and then i was starting to get the 'Are you sure you want to remove' from the ipod.
    I think somethings wrong, this a brand new restore using the US Clock -48 fix.

    This my sound too simple, but I just kept clikning on the arrow next to the selected music and it finally "Kicked" in.
    I live in Europe ,So Be persistent and don't give up !  Aug. 2013

  • Hello, the 'Save As' dialog box used to allow the backspace button to go up one level in the directory when the focus is in the folder contents box but it does not work any more, please help.

    Hello, the 'Save As' dialog box used to allow the backspace button to go up one level in the directory when the focus is in the folder contents box but it does not work any more, please help. BTW the same 'Save As' dialog in other applications still allow the backspace button to go up one level in the directory.

    cor-el,
    I kept forgetting and procrastinating about following your instructions, since I have internet access only for limited amounts of time and usually I am busy with important tasks when I am.
    Out of the blue, the problem corrected itself (the Save As box started to open full screen, then shrunk down to a normal size and the edges can now be dragged to a custom size).
    Even the copy and paste problem in the filenaming area seems to have been less troublesome lately even though there have been no updates to Firefox in a few weeks.
    Even though I marked the solution as not helpful, the problem has in fact been resolved. I will save the solution instructions in case the issue returns.

  • The g, h and backspace on my keyboard are not working even after replacing with a new one.

    The g, h and backspace on my keyboard are not working even after replacing with a new one. I have also updated my BIOS still d same. Please help me ASAP.
    ...am waiting for a QIUCK RESPONSE

    How does a usb keyboard attached externally work?
    You might try a "hard reset" where you remove battery and AC charger, hold down power button 20-30 seconds and then reassemble and turn on. Reset BIOS (F10) to default settings, too. 

  • Key fn + Backspace does not work with apple wireless keyboard

    Hello,
    I want to user the WIndows Key DEL. However, the apple wireless keyboard dosn't have such a key. I read, that FN + Backspace will solve this. It does not work on my apple wireless keyboard. I'm using BootCamp 3.2 and WIndows XP, running on a Mac Mini 2010.
    In addition, I also read, that FN + Cursor Left sould work like POS1. But this doesn't work, too.
    Windows shows for the keyboard: Deutsch (Apple)
    Regards Dirk

    Hi mate,
    This worked for me:
    http://code.google.com/p/uawks/
    Cheers,
    Anthony

  • Input Textfields not working in fullscreen mode

    Input Textfields not working in fullscreen mode any one help me.

    Quotes from Adobe:
    "Users cannot enter text in text input fields while in full-screen mode. All keyboard input and key-related ActionScript is disabled while in full-screen mode, with the exception of the keyboard shortcuts that take the viewer out of full-screen mode."
    Check with this article to know more: http://www.adobe.com/devnet/flashplayer/articles/full_screen_mode.html

  • JMaskField mask input : delete and backspace do not work

    I am using this package for formatted input.
    Delete and backspace do not work if the field is created with a default text as in the code snippet I attach. Did somebody managed this to work? How? delete and backspace work badly in everycase anyway.
    best regards
    -Mangi
    MaskMacros macros = new MaskMacros();
    macros.addMacro('*',"[a-zA-Z0-9]");
    macros.addMacro('#', "[0-9]");
    macros.addMacro('@', "[a-zA-Z]");
    macros.addMacro('%',"[A-Z]");
    macros.addMacro('*',"[a-zA-Z0-9]");
    MaskField2 k = new MaskField2("CODE******",macros);

    Nope, I don't think those keys are even "firing" as another person worded it. I can push the buttons down, so they aren't stuck but it doesn't seem to be sending any signal.

Maybe you are looking for

  • Data issues with the Rzzr

    I recently bought the droid Razr and have had some issues.  First off I seem to get a decent amount of data connection disconnects.   Also when I live on Long Island and work in Manhattan.  Where I live I only get 3g and the connection is slooooow.  

  • MIDI help with Logic X

    Hoping someone can shed some light on a somewhat elusive topic. I am new to recording, so maybe I just don't know where to look.  Info on recording each pad on a different track is pretty sparse. I have the TD-15KV set of Roland V-drums.  I like a lo

  • Is there adobe flash player on any of the ipad

    is there adobe flash player on any of the ipad

  • How will I know, if the asynchronous message fails in XI? Acknowledgment?

    Hi guys, I have a FILE->XI->FILE scenario and sometimes the inbound message failsin XI (bad structure or whatever esle).. Is it possible to receive some message, that the original message failed? I have read topics about acknowledgments, but I didn't

  • Reciever to match my speakers

    I was given a insignia 5.1 home theatre package as a gift but i dont know what reciever or what else i need to or should get with it. I have a 42'' 720hd insignia tv but i would mostly use it for my ps3. Im not looking to spend a ton of money or have