Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Textfield Limit

  • 14-04-2006 04:33PM
    #1
    Registered Users, Registered Users 2 Posts: 622 ✭✭✭


    Hi all,

    Can anybody tell me what is the most simplest way to only allow numbers within a textfield, and how I can limit the text size of the user to 2, here is my creation of the textfield, and I require th get as its reading from the users input.

    Also I already have a listener to retrieve the value of the textfield to correspond to the listener of that

    // Create the Text fields for the Record Details Panel
    final JTextField Age_TextField = new JTextField(node.getFileSizeText());
    Age_TextField.setHorizontalAlignment(JTextField.CENTER);

    // Add the Action Listioner to the textfields of the Record Details Panel
    Age_TextField.getDocument().addDocumentListener
    (
    new DocumentListener()
    {
    public void changedUpdate(DocumentEvent e)
    {
    RootNode node = (RootNode)getSelectedNode();
    node.setFileSizeText(Age_TextField.getText());
    setConfigChanged(true);
    }

    public void insertUpdate(DocumentEvent e)
    {
    RootNode node = (RootNode)getSelectedNode();
    node.setFileSizeText(Age_TextField.getText());
    setConfigChanged(true);
    }

    public void removeUpdate(DocumentEvent e)
    {
    RootNode node = (RootNode)getSelectedNode();
    node.setFileSizeText(Age_TextField.getText());
    setConfigChanged(true);
    }
    }
    );


    i read that all it is possible to input the code within the:
    public void insertUpdate(DocumentEvent e) ....event listener
    {
    ...code
    }

    can anybody help me please......

    thanks all.......


Comments

Advertisement