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() {
}
Can't we just page him?
class RunMe extends Thread {
private void loadPage() {
// ...
}
@Override
public void run() {
loadPage();
}
}
© 2024 OneMinuteCode. All rights reserved.