The JavaFX Runtime contains a series of classes created specifically to build rich application interfaces. The general structure of JavaFX Runtime functionality is shown on the following picture.
![]() Figure 1: JavaFX GUI Structure |
Below is a summary of JavaFX Runtime packages and classes employed in tutorial demos and practical examples.
Package | Purpose |
---|---|
javafx.animation | Contains classes that can be used to apply animation effects. Attributes of any object, either visual or non-visual, can be animated over time by the classes in this package |
javafx.ext.swing | Contains wrappers for Swing components, for example Frame, ComboBox, and List |
javafx.scene | Provides classes that align and orient the UI elements and operate with fonts |
javafx.scene.effect | Has classes that can apply various effects to the application. The javafx.scene.effect supports blurring, rendering shadows, color adjusting, blending, glowing, toning, inverting, reflecting, blooming, and flooding operations |
javafx.scene.effect.light | Has classes that provide 2D and 3D lighting effects to the application |
javafx.scene.geometry | Provides classes that are responsible for different drawing operations, for example drawing lines, geometrical objects, curves, or shapes |
javafx.scene.image | Includes classes to operate with images |
javafx.scene.layout | Is responsible for the layout of GUI elements of the application |
javafx.scene.media | Contains classes that are responsible for media playback | javafx.scene.paint | Contains classes that define color and different color patters |
javafx.scene.text | Provides classes to operate with text | javafx.scene.transform | Includes classes that apply transformations to objects |
Class | Public Attributes | Public Functions | Purpose |
---|---|---|---|
Interpolator | DISCRETE, EASEBOTH, EASEIN, EASEOUT, LINEAR | SPLINE(x1: Number, y1: Number, x2: Number, y2: Number) | Controls the timing of an animation |
KeyFrame |
action, time, timelines, values |
- | Represents one specific point in time in your animation |
KeyValue | interpolate, target, value | - | Represents an object that is displayed in your animation in a specific point of time |
Timeline |
autoReverse, direction, keyFrames, repeatCount
INDEFINITE |
pause(), resume(), start(), stop() | Holds a sequence of KeyFrame objects |
Class | Public Attributes | Public Functions | Purpose |
---|---|---|---|
Canvas | background, content | - | A graphical container for the Node objects |
ComboBox | editable, items, selectedIndex, selectedItem, text | getJComboBox() | Defines a component that combines a button or editable field and a drop-down list |
Component | enabled, font, foreground, halign, height, hisbaseline, hmax, hmin, hpref, name, preferredSize, valign, visbaseline, visible, vmax, vmin, vpref, width, x, y | fromJComponent(jComponent: JComponent), getComponentFor(jComponent: JComponent), getJComponent(), getName(), getParent(), getRootJComponent() |
Represents a common component ancestor |
ComponentView | component | impl_createSGNode() | Represents a node that contains Component objects. Is used for adding components to a graphical scene. |
GridPanel | icon, iconified, menus, resizable, title | - | Creates a panel applying the grid layout that lays out components in a rectangular grid. The panel is divided into equal-sized rectangles, and one component is placed in each rectangle |
SwingFrame | items, selectedIndex, selectedItem | getJFrame() | Defines a top-level window with a title and a border |
List | background, borderless, columns, editable, horizontalAlignment, selectOnFocus, text | getJList() | Defines an array of ListItem objects to be displayed by this list |
TextField | action: Void, verify: function(:String) | getJTextField(), getSelectionEnd(), getSelectionStart(), select(start: Integer, end: Integer), selectAll() | Defines a text component that enables editing a single line of text |
CheckBox | getJCheckBox() | An implementation of a check box — an item that can be selected or deselected, and which displays its state to the user. By convention, any number of check boxes in a group can be selected. | |
Label | horizontlAlignment, horizontalTextPosition, icon, labelFor, text, vertical Alignment, verticalTextPosition | getJLabel() | Defines a display area for a short text string or an icon, or both. |
Class | Public Attributes | Public Functions | Purpose |
---|---|---|---|
Cursor | content | - | Represents an area of the screen onto which the application can draw or from which the application can trap input events from the user |
Node | anchorX, anchorY, blocksMouse, cache, clip, clipAntialiased, cursor, effect, horizontalAlignment, id onKeyPressed: function(:KeyEvent), onKeyReleased: function(:KeyEvent), onKeyTyped: function(:KeyEvent), onMouseClicked: function(:MouseEvent), onMouseDragged: function(:MouseEvent), onMouseEntered: function(:MouseEvent), onMouseExited: function(:MouseEvent), onMouseMoved: function(:MouseEvent), onMousePressed: function(:MouseEvent), onMouseReleased: function(:MouseEvent), onMouseWheelMoved: function(:MouseEvent) opacity, rotate, scaleX, scaleY, shearX, shearY, transform, translateX, translateY, verticalAlignment, visible |
contains(x: Number, y: Number), getBoundsHeight(), getBoundsWidth(), getBoundsX(), getBoundsY(), getHeight(), getParent(), getWidth(), getX(), getY(), hasFocus(), isFocusable(), isMouseButtonDown(buttonNumber: Integer), isMouseOver(), lookup(id: java.lang.String), requestFocus(), toBack(), toFront() | Base class for scene graph nodes. The Node class defines a "local" coordinate system: x increases to the right, y increases downwards |
CustomNode | Inherited from the Node class | create() | A key class for creating your own nodes. You can define your own node classes by extending this class and implementing its create function |
Group | content layout: function(:Group) |
- | Represents a list of nodes. Is also used to provide a common behavior for a list of nodes |
HorizontalAlignment | CENTER, LEADING, LEFT, RIGHT, TRAILING | toString() | Represents the horizontal alignment in an area |
VerticalAlignment | BOTTOM, CENTER, TOP | toString() | Represents the vertical alignment in an area |
Class | Public Attributes | Public Functions | Purpose |
---|---|---|---|
ColorAdjust | input, brightness, contrast, hue, saturation | getImpl() | Enables per-pixel adjustments of hue, saturation, brightness, and contrast |
DropShadow | color, offsetX, offsetY, radius | getImpl() | Renders a shadow behind the given content with the specified color, radius, and offset |
GaussianBlur | input, radius | getImpl() | Applies a Gaussian blur effect with a configurable radius |
Class | Public Attributes | Public Functions | Purpose |
---|---|---|---|
DistantLight | azimuth, elevation | getImpl() | Defines a distant light source with the azimuth and elevation |
PointLight | x, y, z | getImpl() | Creates a light source at a given position in 3D space |
Class | Public Attributes | Public Functions | Purpose |
---|---|---|---|
Arc | centerX, centerY, length, radiusX, radiusY, startAngle, type |
impl_createSGNode() | Represents a 2D arc object, defined by a center point, start angle (in degrees), angular extent (length of the arc in degrees), and an arc type |
Circle | centerX, centerY | impl_createSGNode() | Creates a new circle with the specified radius and center location measured in pixels |
Rectangle | arcHeight, arcWidth, height, width, x, y | impl_createSGNode() | Defines a rectangle with the specified size and location |
Shape | fill, smooth, stroke, strokeDashArray, strokeDashOffset, strokeLineCap, strokeLineJoin, strokeMiterLimit, strokeWidth |
impl_getSGAbstractShape(), ofTheWay(endVal: java.lang.Object, t: Number) | Provides definitions for common shapes and objects that represent some form of geometric shapes. Gives stroke and fill style to all shapes |
Class | Public Attributes | Public Functions | Purpose |
---|---|---|---|
Image | backgroundLoading, placeholder, height, width, progress, size, url | cancel(), fromBufferedImage(image: java.awt.image.BufferedImage), getBufferedImage() | Represents graphical images |
ImageView | height, size, width, x, y, image | impl_createSGNode() | Represents nodes to render images |
Class | Public Attributes | Public Functions | Purpose |
---|---|---|---|
HBox | spacing | - | Renders a list of tiles horizontally |
VBox | spacing | - | Renders a list of tiles vertically |
Class | Public Attributes | Public Functions | Purpose |
---|---|---|---|
Media | duration, resolutionX, resolutionY, source
onError: function(:MediaError) |
getMetadata(key: java.lang.String) | Represents a media resource, contains information about the media, such as its source, resolution, and metadata. |
MediaPlayer | autoPlay, balance, currentCount, currentTime, fader, media, mute, paused, rate, repeatCount, startTime, status, stopTime, supportsMultiViews, timers, volume
BUFFERING, PAUSED, PLAYING, REPEAT_FOREVER, REPEAT_NONE, STALLED onBuffering: function(:Duration), onEndOfMedia: function(), onError: function(:MediaError), onRepeat: function(), onStalled: function(:Duration) |
pause(), play() | Provides the controls for playing media. Is used in combination with the Media and MediaView classes to display and control media playing. |
MediaView | mediaPlayer, compositable, fullScreen, mediaPlayer, onError, preserveAspectRatio, rotatable, transformable
Inherited from the Node class: anchorX,anchorY, blocksMouse, cache, clip, clipAntialiased, cursor, effect, horizontalAlignment, id, onKeyPressed, onKeyReleased, onKeyTypedonMouseClicked, onMouseDragged, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onMouseWheelMoved, opacity, rotate, scaleX, scaleY, shearX, shearY, transform, translateX, translateY, verticalAlignment, visible |
Inherited from the Node class: contains(x: Number, y: Number), getBoundsHeight(), getBoundsWidth(), getBoundsX(), getBoundsY(), getHeight(), getParent(), getWidth(), getX(), getY(), hasFocus(), isFocusable(), isMouseButtonDown(buttonNumber: Integer), isMouseOver(), lookup(id: java.lang.String), requestFocus(), toBack(), toFront() |
A Node object that provides a view of Media being played. Provides attributes to support transformation, effects, clip shaping, and translucency. |
MediaTimer | action, time | - | Specifies a time and an action to be performed when the media reaches that time |
MediaError | cause, message
MEDIA_CORRUPTED, MEDIA_INACCESSIBLE, MEDIA_UNAVAILABLE, MEDIA_UNSPECIFIED, MEDIA_UNSUPPORTED, OPERATION_UNSUPPORTED, UNKNOWN |
- | Specifies types of media error |
Class | Public Attributes | Public Functions | Purpose |
---|---|---|---|
Color | ALICEBLUE, ANTIQUEWHITE, AQUA, AQUAMARINE, AZURE, BEIGE, BISQUE, BLACK, BLANCHEDALMOND, blue, BLUE, BLUEVIOLET, BROWN, BURLYWOOD, CADETBLUE, CHARTREUSE, CHOCOLATE, CORAL, CORNFLOWERBLUE, CORNSILK, CRIMSON, CYAN, DARKBLUE, DARKCYAN, green, red, opacity, and others | color(red: Number, green: Number, blue: Number, opacity: Number), color(red: Number, green: Number, blue: Number), fromAWTColor(c: java.awt.Color), getAWTColor(), getAWTPaint(), hsb(hue: Number, saturation: Number, brightness: Number, opacity: Number), hsb(hue: Number, saturation: Number, brightness: Number), ofTheWay(endVal:java.lang.Object, t: Number), rgb(red: Integer, green: Integer, blue: Integer, opacity: Number), rgb(red: Integer, green: Integer, blue: Integer), toString(), web(color: java.lang.String, opacity: Number), web(color: java.lang.String) | Represents colors using predefined constants or standard constructors. |
LinearGradient | cycleMethod, endX, endY, startX, startY, proportional, stops | getAWTPaint() | Fills a shape with a linear color gradient pattern |
Paint | - | getAWTPaint() | Defines how color patterns can be generated for graphics operations |
RadialGradient | cycleMethod, centerX, centerY, focusX, focusY, radius, proportional, stops | getAWTPaint() | Fills a shape with a circular radial color gradient pattern |
Stop | color, offset | - | Defines one element of the ramp of colors to use on a gradient |
Class | Public Attributes | Public Functions | Purpose |
---|---|---|---|
Text | content, editable, font, selectOnFocus, textOrigin, x, y action: function(), verify: function(:String) |
getSelectionEnd(), getSelectionStart() | Defines a node that displays a single line of text |
TextOrigin | BASELINE, BOTTOM, TOP | toString() | Represents the text origin |
Class | Public Attributes | Public Functions | Purpose |
---|---|---|---|
Rotate | angle, x, y | impl_getAffineTransform() | Represents an Affine object that rotates coordinates around an anchor point |
Scale | x, y |
impl_getAffineTransform() | Represents an Affine object that scales coordinates by the specified factors |
Transform | impl_node |
affine(m00: Number, m01: Number, m02: Number, m10: Number, m11: Number, m12: Number), impl_getAffineTransform(), rotate(angle: Number, x: Number, y: Number), scale(x: Number, y: Number), shear(x: Number, y: Number), translate(x: Number, y: Number) | Provides static functions to perform rotating, scaling, shearing, and translation transformations for Affine objects |