I want to know how to run the loadPage method inside the run method

Asked 1 years ago, Updated 1 years ago, 469 views

I have to run the loadPage method when the button is clicked using a new run method, but I don't know what code to write in the run method.

private void loadPage() {
    urlButton.setDisable(true);
    textFlow.getChildren().clear();
    try {
        URL url = new URL(DELAY_URL + urlField.getText());
        Scanner site = new Scanner(url.openStream());
        while (site.hasNextLine()) {
            String line = site.nextLine();
            textFlow.getChildren().add(new Text(line + "\n"));
        } } //whilte
    } } catch (IOException ex) {
        textFlow.getChildren().add(new Text(ex.getMessage()));
    } } //try
    urlButton.setDisable(false);
} } //loadPage

public void run() {
}

thread java javafx

2022-11-18 19:59

1 Answers

Can't we just page him?

class RunMe extends Thread {
    private void loadPage() {
        // ...
    }

    @Override
    public void run() {
        loadPage();
    }
}


2022-11-18 22:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.