Java Reference
In-Depth Information
webEngine.getLoadWorker().stateProperty().addListener(
(ObservableValue<? extends State> observable,
State oldValue, State newValue) -> {
System.out.println("done!" + newValue.toString());
if (newValue != State.SUCCEEDED) {
return;
}
Weather weather = parse(webEngine.getDocument());
warningMessage.setText("Warning: "
+ weather.currentWeatherText +
"\nTemp: " + weather.temperature + "\n
E-mailed others");
... // the rest of changed() method
}); // end of addListener method
This code sets the OnAlert property, which is an event handler that responds
when the Panic or Calm Down buttons are pressed:
webView.getEngine().setOnAlert((WebEvent<String> evt) -> {
warningMessage.setOpacity("warning".equalsIgnoreCase(evt.getData())
? 1d : 0d);
});
You add the following code as a private method that is responsible for creating a
text node ( javafx.scene.text.Text ). It is used as the warning message when
the user presses the Panic button:
private Text createMessage(Color color, String
message) {
DropShadow dShadow = new DropShadow();
dShadow.setOffsetX(3.5f);
dShadow.setOffsetY(3.5f);
Text textMessage = new Text();
textMessage.setText(message);
textMessage.setX(100);
textMessage.setY(50);
textMessage.setStrokeWidth(2);
textMessage.setStroke(Color.WHITE);
Search WWH ::




Custom Search