N
N
Neonoviiwolf2019-06-01 11:09:39
Java
Neonoviiwolf, 2019-06-01 11:09:39

How to override the TextField method if it has already been created?

Good!
There is a code

package com.extensions.textFild;

import javafx.scene.control.TextField;

public class TextFieldFiltersInput extends TextField {

    @Override
    public void replaceText(int start, int end, String text) {

        if (!"1234567890.\b".contains(text)) {
            text = "";
        }
        super.replaceText(start, end, text);
    }
}

works as it should, but here is inheritance, but how to do this through composition, I can’t figure out what to call?
package com.extensions.textFild;

import javafx.scene.control.TextField;

public class testText {
    private TextField textField;

    public testText(TextField textField) {
        this.textField = textField;
        
    }
}

Why is it necessary? I had to use the first option in FXML, it works, but Scene Builder cannot open, and I have EAP in the IDE, and the built-in is broken in the new version. Yes, and for self-development is useful

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question