Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Textfield Limit

Options
  • 14-04-2006 4:33pm
    #1
    Registered Users Posts: 618 ✭✭✭


    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