I have this field in which I insert port number. I would like to convert the string automatically into number:
fieldNport = new TextField();
    fieldNport.setPrefSize(180, 24);
    fieldNport.setFont(Font.font("Tahoma", 11));
    grid.add(fieldNport, 1, 1);
Can you tell how I can do this? I cannot find suitable example in stack overflow.
EDIT:
Maybe this:
 fieldNport.textProperty().addListener(new ChangeListener()
        {
            @Override
            public void changed(ObservableValue o, Object oldVal, Object newVal)
            {
                try
                {
                    int Nport = Integer.parseInt((String) oldVal);
                }
                catch (NumberFormatException e)
                {
                }
            }
        });
 
     
     
    