JavaFX 2

Developing Your Second JavaFX Program: "More Cowbell!" (Getting a Jump Start in JavaFX) Part 1

If you’re familiar with the Saturday Night Live television show, you may have seen the More Cowbell sketch, in which Christopher Walken’s character keeps asking for "more cowbell" during a Blue Oyster Cult recording session. The following JavaFX example program covers some of the simple but powerful concepts of JavaFX in the context of an […]

Developing Your Second JavaFX Program: "More Cowbell!" (Getting a Jump Start in JavaFX) Part 2

Creating an Instance of the Model, and the Magic of Binding One of the powerful aspects of JavaFX is binding, which enables the application’s UI to easily stay in sync with the state, or model, of the application. The model for a JavaFX application is typically held in one or more classes, in this case […]

Surveying JavaFX Features (Getting a Jump Start in JavaFX)

We close this topic by surveying many of the features of JavaFX, some of which are a review for you. We do this by describing several of the more commonly used packages and classes in the JavaFX SDK API. The javafx.stage package contains: • The Stage class, which is the top level of the UI […]

Introduction to Node-Centric Uls (Creating a User Interface in JavaFX)

Life is the art of drawing without an eraser. —John W. Gardner First on the agenda is to get you acquainted with the theater metaphor used by JavaFX to express user interfaces and to cover the significance of what we call a node-centric UI. Creating a user interface in JavaFX is like creating a theater […]

Setting the Stage (Creating a User Interface in JavaFX) Part 1

The appearance and functionality of your stage will depend on the platform on which it is deployed. For example, if deployed in a web browser, your stage will be a rectangular area, called an applet, within a web page. The stage for a JavaFX program deployed via Java Web Start will be a window. Understanding […]

Setting the Stage (Creating a User Interface in JavaFX) Part 2

Obtaining Program Arguments The first new concept introduced by this program is the ability to read the arguments passed into a JavaFX program. The javafx.application package includes a class named Application that has application lifecycle related methods such as launch(), init(), start(), and stop(). Another method in the Application class is getParameters(), which gives the […]

Making a Scene (Creating a User Interface in JavaFX) Part 1

Continuing on with our theater metaphor for creating JavaFX applications, we now discuss putting a Scene on the Stage. The Scene, as you recall, is the place in which the actors and props (nodes) visually interact with each other and the audience (the users of your program). Using the Scene Class: The OnTheScene Example As […]

Making a Scene (Creating a User Interface in JavaFX) Part 2

Painting the Scene’s Background The Scene class has a fill property whose type is javafx.scene.paint.Paint. Looking at the JavaFX API will reveal that the known subclasses of Paint are Color, LinearGradient, and RadialGradient. Therefore, a Scene’s background may be filled with solid colors and gradients. If you don’t set the fill property of the Scene, […]

Handling Input Events (Creating a User Interface in JavaFX)

So far we’ve shown you a couple of examples of event handling. For example, we used the onAction event handler to execute code when a button is clicked. We also used the onCloseRequest event handler of the Stage class to execute code when the Stage has been requested externally to close. In this section, we […]

Animating Nodes in the Scene (Creating a User Interface in JavaFX) Part 1

One of the strengths of JavaFX is the ease with which you can create graphically rich user interfaces. Part of that richness is the ability to animate nodes that live in the Scene. At its core, animating a node involves changing the value of its properties over a period of time. Examples of animating a […]