O'Reilly logo

JavaFX 2.0: Introduction by Example by Carl Dea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4-4. Responding to HTML Events

Problem

You begin to feel sorry for your other cube mates who are also oblivious to the outside world. A storm is approaching and you want to let them know to take their umbrella before leaving the building.

Solution

Add a Panic Button to your weather application that will simulate an e-mail notification. A Calm Down button is also added to retract the warning message.

The following code implements the weather application with additional buttons to warn and disregard a warning of impending stormy weather:

    @Override public void start(Stage stage) { ...  // template building

This code will add HTML buttons with the onclick attributes set to invoke the JavaScript alert function:

        template.append("<body ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required