Restricting JTable Character Input

I wish to limit the input of a JTable column to digits only. I have done this with JTextfields, but I cant figure how to apply that to tables.
Can anyone point me to example code or tutorials which show how this is done for JTable cells?
Many thanks in advance.

The Swing tutorial has a section on JTables. It gives an example on how to restrict a column to numeric values only. Best of all it reuses the Custom Document that you used for your JTextField.
file:///C:/Java/tutorial/uiswing/components/table.html#validtext

Similar Messages

  • Converting character input value to number or money

    Hello everyone. I have an element, Overtime Allowance.
    This has inputs:
    proportion
    hourly amount
    number of hours
    the formula is proportion * hourly amount * number of hours
    Now, I want to restrict the proportion input value to only two values, 1 and 1.2
    to do this, I created a value set and attached it to the input value
    I had to change the datatype of the proportion input value to Character since the number data type does not support valuesets/lookups
    the problem comes in the formula
    I enter
    overtime = to_number(proportion) * hourly amount * number of hours
    but I get an error
    using
    overtime = proportion* hourly amount * number of hours
    results in an error as well
    Does anybody know how to sort this one out?
    Many Thanks

    hi Igwe,
    I managed to create a Valueset number with 1 and 1.2 values only.
    Format Type: Number
    Maximum Size: 3
    Precision 1
    Min value: 1.0
    Max value: 1.2
    Indipendent
    Then I've entered Valueset values 1.0 and 1.2
    It worked fine with me... what kind of issue are you experiencing?
    Edited by: Giuseppe Bonavita on 19-Mar-2013 10:09 to add:
    sorry I see what you mean... the input value does not accept a valueset for validating.

  • How to restrict the user input textfield to an Integer?

    Hello there;
    Here is my problem, and i need your help.
    I have a mssql 2005 server as my back end database;
    I have designed a web application from which i can load a specific table in my database.
    One of my table column is of integer type and i want to restrict the user to only entered an integer in the textfield.
    I have try the integer converter from the "converters" section of the pallete. The result is that its actually restrict the user input to be an integer, but i can't load the database, obtaining a java.lang.Int error message.
    Next i have tried using int theid=int.parseInt........ but i am receiving a syntax error of the type cannot find symbol parseInt.
    I can't just work this out!
    Could anybody help please.

    As has been stated in previous replies you can check that the value in the TextField is parseable as an Integer by using Integer.parseInt(fieldVariable.getText()). However, you can also restrict what characters can be entered into the text field, like so:
    Assume your field variable is textField1 then the KeyTyped event for the text field:
    private void textField1KeyTyped(java.awt.event.KeyEvent evt) {
         if (evt.getKeyChar() < '0' || evt.getKeyChar() > '9') {
              evt.consume();
    }will only allow the numeric characters (i.e., 0-9) to be typed into the field. Keep in mind that in this case the backspace, delete, home, arrow, etc, keys will not delete characters, move the cursor, etc, so if you want those you have to test for them as well.

  • Curve 9380: Return from character input to QWERTY keyboard

    Hello,
    I own BlackBerry Curve 9380 smartphone (all touch, without physical keyboard).
    I have the following issue:
    Consider you're writing a text message, when you need a question mark you're tapping on the "&% 123"  button in the left-down corner and selecting the question mark. In order to return back to the original QWERTY keyboard you need to tap on the button again, now "ABC".
    Is that possible to automate the return to the QWERTY keyboard from character input keyboard after tapping the "space" button?
    Keyboard is returning automatically back only if you will tap on the "Enter" button.
    Adding the "space" button would be a great enhancement for touch-based devices featuring BlackBerry 7 OS.
    Thank you.
    P.S. I didn't find any better medium for my concern than this forum, if somebody knows how to reach directly to software engineering group, please let me know.

    You still have the constructor declared inside the main method! :-)
    public class TrySimpleVectorWithKeyboardInput
    public static void main(String[] args)
    public TrySimpleVectorWithKeyboardInput()
    {}Move the two lines to outside the main. It should look something like this..
    import java.util.*;
    import java.io.*;
    public class TrySimpleVectorWithKeyboardInput {
        public TrySimpleVectorWithKeyboardInput() {
          // constructor code goes here
        public static void main(String[] args)    {
            Vector names = new Vector();       
            FormattedInput kb = new FormattedInput();       
            for (int i = 0; i < 5; i++) {         
                try {           
                    System.out.print("Enter a  name ");           
                    names.add( kb.readString());         
                } catch (InvalidUserInputException e) {           
                    System.out.println("InvalidUserInputException thrown. \n" + e.getMessage());         
            System.out.println("\nThe names in the vector are:\n ");       
            Iterator j = names.iterator();       
            while (j.hasNext()) {
                System.out.println(j.next());       
    }

  • Character input disaplay after " " when show up in af:outputFormatted

    When I input text after "<" in text field and save it in database varchar2 column. It is found that all character disappear after "<" when I retrieve it with af:outputFormatted. If I retrieve it with outputText. It can show up properly.
    For example, I input <abc> in the text field. I then the retrieve character from database. All the text <abc> disappear.

    Sorry for typo in title: it should read as "character input disappear after "<" when show up in <af:outputFormatted
    If I input &lt;abc>, then, the text <abc> show up properly
    hence, what can be done to fix it if I just input <abc> instead of &lt;abc>

  • Weird character input in textfield when hitting CTRL+somekeys

    Hi,
    Whenever an input textfield has the focus, some ctrl+something key combinations (for example ctrl+s, ctrl+o) produce some weird character input, that is, these weird characters (certainly non-ascii) appear in the textfield as if you had typed them.
    This is obviously a bug, but is there any workaround? How can I prevent these combinations of keys to produce any text input at all? (without removing the focus from the textfield)?
    This only happens in Flash Player (and Adobe AIR): I've never seen those character appear in any application as a result of ctrl+S, ctrl+O or any key combination (except alt+<numerical character code>)
    Thanks in advance
    m.

    I'm not entirely sure that the issue we're facing is a font issue - I've managed to set a font for the TextField in question that can handle Japanese as well as English characters (in this case I'm using the Bitstream Cyberbit font), following guidelines in an article on the subject:
    http://www.onjava.com/pub/a/onjava/2001/04/12/internationalization.html
    If I enter the Japanese characters in a window of a native application, and then copy & paste into the TextField in my Java applet, they appear when using this font, and it seems like the applet can interpret them OK (in IE at least, still haven't tested in NS as yet) - the problem is that when entering the characters directly into the applet using the Win2k IME facility, they only appear as question marks.
    Damian.

  • Double character input error when entering data in numbers using Bluetooth keyboard.

    Using a bluetooth keyboard (Logitech) sometimes causes a double character input when entering data in numbers.
    For example if wish to enter the number "22" or the word "in" they become "2222" and "iinn". Pressing enter of tab also causes a double jump
    This problem is not always solved by turning keyboard off and on or by closing down and restarting numbers.
    This problem does not occur in any other app.
    I have used 2 different Logitech keyboards (ultra-slim and the recently new folio keyboard) and both caused the same problem.
    The error is sporadic but frequent and has lead to me often having to switch back to touch input.
    Very frustrating considering these excellent keyboards are ideal for using in numbers when working correctly!
    ANy advice would be much appreciated

    Zombie,
    Not much help I'm afraid, but I just saw your post & wanted to let you know that I have the same problem, but for me it manifests itself in many apps, and it happens with the Apple bluetooth keyboard
    . The only thing I've noticed is that it only seems to happen when I first start typing after not using the keyboard for a while (I'm not sure how long a while is, but maybe 30 seconds or so). Then I'll type & the first few letters will be fine, and then one letter double-types, and then it's fine again until I stop using it for whatever the threshold amount of time is. I'm guessing that it has something to do with the iPad's battery management & that it's shutting off the connection to the keyboard or something & once it picks it back up, then it double-types that letter.
    At least in Pages, it isn't as big of a deal because I know it's coming, I can correct it & then type for a long time. In Numbers, my keyboard use is much less consistent, so I need to be more cognisant of it.

  • Japanese character input.

    I want to save the Japanese character input from html forms into the Oracle Database
    using the euc character set. Most of the users use Windows PC, so I guess most
    of the input would be using s-jis or MS932.
    Do I need to write the character code conversion methods from s-jis and/or MS932
    to euc and vice versa or does the weblogic server do the conversion internally
    Thanks.
    Sanjay.

    Sanjay.
    You can do that by specifying EUC-JP for input-charset element of
    weblogic.xml. See the following link for more detail.
    http://e-docs.bea.com/wls/docs61///////webapp/weblogic_xml.html#1031571
    For Oracle to work with EUC charset, you need to set the environment
    variable of NLS_LANG=japanese_japan.JA16EUC. You don't need to write the
    code conversion method.
    Hope this helps,
    Reiji
    "sanjay" <[email protected]> wrote in message
    news:3c046d39$[email protected]..
    >
    I want to save the Japanese character input from html forms into theOracle Database
    using the euc character set. Most of the users use Windows PC, so I guessmost
    of the input would be using s-jis or MS932.
    Do I need to write the character code conversion methods from s-jis and/orMS932
    to euc and vice versa or does the weblogic server do the conversioninternally
    Thanks.
    Sanjay.

  • Chinese Character Input?

    Hi, I have snow leopard and I was wondering how to do the chinese character input, I know that you use the trackpad, but where do I go to do it? Thanks

    First of all you need to turn-on the features on the International Panel Located in the Preference area.
    I have encounter some bugs on the TrackPad Input. It recognize the characters quite well but, it is quite difficult to delete or accept characters you will understand what I'm saying when you tried it out.

  • Chinese Character Input (trackpad) and Spaces

    I use Spaces religiously and I can't seem to find a way to enable the Chinese Character Input (trackpad) for any space other than the first space. If I enable Chinese Character Input (controlshiftspacebar) on any space but the first one (upper left) then the Chinese Character Input dialog appears on the first space but not the space I am on. Anyone else experiencing this?
    ta

    http://discussions.apple.com/thread.jspa?messageID=10068621&#10068621

  • If there is any restriction for procedure input parameter

    Hello expert,
    I create a oracle precedure, with a input parameter, but when I used this procedure in SAP BO, it showed following error message:
    " a database error occured. the database error text is : cannot parse the stored procedure query: unable to parse stored procedure specification . (WIS 10901)"
    I found if I input a value for this parameter including '&', above error displayed.
    so , will you please tell me if there is any restriction for procedure input parameter?
    Many Thanks,

    843178 wrote:
    I create a oracle precedure, with a input parameter, but when I used this procedure in SAP BO, it showed following error message:
    " a database error occured. the database error text is : cannot parse the stored procedure query: unable to parse stored procedure specification . (WIS 10901)" This is not an Oracle error message. Such a message will have an ORA error code (or PLS code). Neither can stored procedures be executed as queries. They need to be executed via anonymous PL/SQL code blocks.
    So from the sounds of it, the problem in your case is that the PL/SQL procedure call is incorrectly made.
    Calling a PL/SQL procedure needs 2 basic things:
    - make the call code using an anonymous PL/SQL code block
    - use bind variables for passing input and output parameters

  • Japanese character input issues

    We have someone developing a chat client in flash that
    connects to an FMS server. Typing works fine in English, but if you
    try to type Japanese, it spits the characters out one at a time
    into the chat window after pressing return. This makes chat very
    difficult and extremely long for Japanese folks:
    L
    I
    K
    E
    T
    H
    I
    S
    Above is how Japanese would show up. I should mention that
    this happens only on OSX and not Windows. Anybody have any ideas on
    how to fix this? Many thanks!

    Sanjay.
    You can do that by specifying EUC-JP for input-charset element of
    weblogic.xml. See the following link for more detail.
    http://e-docs.bea.com/wls/docs61///////webapp/weblogic_xml.html#1031571
    For Oracle to work with EUC charset, you need to set the environment
    variable of NLS_LANG=japanese_japan.JA16EUC. You don't need to write the
    code conversion method.
    Hope this helps,
    Reiji
    "sanjay" <[email protected]> wrote in message
    news:3c046d39$[email protected]..
    >
    I want to save the Japanese character input from html forms into theOracle Database
    using the euc character set. Most of the users use Windows PC, so I guessmost
    of the input would be using s-jis or MS932.
    Do I need to write the character code conversion methods from s-jis and/orMS932
    to euc and vice versa or does the weblogic server do the conversioninternally
    Thanks.
    Sanjay.

  • How to Restrict Expand for Input Schedule

    Dear Experts,
    In Input Schedule, I am writing Formulas for some cells.
    When I am trying to do u201CExpand Allu201D my formulas are not remaining in the cells.
    Can any body suggest solution.
    Can we restrict Expand for Input Schedule?
    Please help,

    Hi,
       Sorry, I didn't understood well your request and I give you wrong information.
    GetOnlyRange is used you only wants only function to behave in read-only mode. All cells defined in this range will only retrieve values from the DB but no entered value will be sent.
    If you want to keep your formula for some cells, you have to exclude those from the expansion range.
    This means in your RowKeyRange section to define something like
    =EVRNG(E14:E16,E18:E38, ...), not a continue range.
    Hoe this cen help you,
    Mihaela

  • Restricting user to input a maximum number of characters in a JTable cloumn

    Hi all,
    I'me developing a program which should restrict the user with a maximum number of characters input in a JTable column. It should show a msg and restrict the user from typing in, if the number of characters exceed the limit and on clicking cancel it should revert back the changes made to the field.
    Can anybody please help me?
    Thanks in advance,
    Amol

    Hi,
    Try to write your own cell editor.
    There attach an InputVerifier to the JTextField of the editing cell.
    The input verifier can watch for the size of the input and if too many characters you can show a JOptionPane.Dialog.
    Olek

  • How to Cancel restrictions of Dates input box must input?

    when I Create  a activity , On tab Dates , I must Input "From to" "End to", This Type date is Configurated use SPRO. If I do not Input ,It will gives Error messages.
    How can i cancel this restrictions?

    One way ,   i) Figure out what is the Transaction Type for your 'Activity'
    ii) Then Check the Date Profile associated with your Transaction type
    iii) From the Date Profile remove the Date type if you don't need it
    If the Date Profile is Standard , I would suggest create a Copy of the Standard and Remove the one you don't need. Then Specify the Custom date Profile in your Transaction type
    I am not sure if this is something you were looking for..
    Edited by: SKP on Mar 24, 2009 4:50 AM

Maybe you are looking for