Top Description Fields Constructors Methods
org.controlsfx.control

public Class InfoOverlay

extends ControlsFXControl
Class Inheritance
Imports
impl.org.controlsfx.skin.InfoOverlaySkin, javafx.beans.property.BooleanProperty, .ObjectProperty, .SimpleBooleanProperty, .SimpleObjectProperty, .SimpleStringProperty, .StringProperty, javafx.scene.Node, javafx.scene.control.Skin, javafx.scene.image.ImageView

A simple UI control that allows for an information popup to be displayed over a node to describe it in further detail. In some ways, it can be thought of as a always visible tooltip (although by default it is collapsed so only the first line is shown - clicking on it will expand it to show all text).

Shown below is a screenshot of the InfoOverlay control in both its collapsed and expanded states:

Screenshot of InfoOverlay

Field Summary

Modifier and TypeField and Description
private ObjectProperty<Node>
content

* Properties * *

private static final String
DEFAULT_STYLE_CLASS

* Stylesheet Handling * *

private BooleanProperty
private StringProperty

Constructor Summary

AccessConstructor and Description
public
InfoOverlay()

Constructs a default InfoOverlay control with no node or text.

public
InfoOverlay(String
The image file to attempt to load.
imageUrl
,
String
The text to display over top of the image.
text
)

Attempts to construct an InfoOverlay instance using the given string to load an image, and to place the given text string over top of it.

public
InfoOverlay(Node
The arbitrarily complex scenegraph over which the text will be displayed.
content
,
String
The text to display over top of the node.
text
)

Constructs an InfoOverlay instance using the given Node (which can be an arbitrarily complex node / scenegraph, or a simple ImageView, for example), and places the given text string over top of it.

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<Node>
contentProperty()

Returns: an ObjectProperty containing the arbitrarily complex scenegraph over which the text will be displayed.

protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final Node
getContent()

Returns: the arbitrarily complex scenegraph over which the text will be displayed.

public final String
getText()

Returns: The text displayed over top of the content.

public String
getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method.

public final boolean
isShowOnHover()

Returns: whether the overlay on hover of the content node is showing.

public final void
setContent(Node content)

Sets a new value for the contentProperty().

public final void
setShowOnHover(boolean value)

Specifies whether to show the overlay on hover of the content node (and to hide it again when the content is no longer being hovered).

public final void
setText(String text)

Specifies the text to display over top of the content.

public final BooleanProperty
showOnHoverProperty()

Returns: A BooleanProperty representing whether the overlay on hover of the content node is showing.

public final StringProperty
textProperty()

Returns: A StringProperty representing the text displayed over top of the content.

Inherited from org.controlsfx.control.ControlsFXControl:
getUserAgentStylesheet

Field Detail

contentback to summary
private ObjectProperty<Node> content

* Properties * *

DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS

* Stylesheet Handling * *

showOnHoverback to summary
private BooleanProperty showOnHover
textback to summary
private StringProperty text

Constructor Detail

InfoOverlayback to summary
public InfoOverlay()

Constructs a default InfoOverlay control with no node or text.

InfoOverlayback to summary
public InfoOverlay(String imageUrl, String text)

Attempts to construct an InfoOverlay instance using the given string to load an image, and to place the given text string over top of it.

Parameters
imageUrl:String

The image file to attempt to load.

text:String

The text to display over top of the image.

InfoOverlayback to summary
public InfoOverlay(Node content, String text)

Constructs an InfoOverlay instance using the given Node (which can be an arbitrarily complex node / scenegraph, or a simple ImageView, for example), and places the given text string over top of it.

Parameters
content:Node

The arbitrarily complex scenegraph over which the text will be displayed.

text:String

The text to display over top of the node.

Method Detail

contentPropertyback to summary
public final ObjectProperty<Node> contentProperty()
Returns:ObjectProperty<Node>

an ObjectProperty containing the arbitrarily complex scenegraph over which the text will be displayed.

createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
getContentback to summary
public final Node getContent()
Returns:Node

the arbitrarily complex scenegraph over which the text will be displayed.

getTextback to summary
public final String getText()
Returns:String

The text displayed over top of the content.

getUserAgentStylesheetback to summary
public String getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

Doc from javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls.

The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath.

Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.



package com.example.javafx.app;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MyApp extends Application {

    @Override public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
Annotations
@Override
isShowOnHoverback to summary
public final boolean isShowOnHover()
Returns:boolean

whether the overlay on hover of the content node is showing.

setContentback to summary
public final void setContent(Node content)

Sets a new value for the contentProperty().

setShowOnHoverback to summary
public final void setShowOnHover(boolean value)

Specifies whether to show the overlay on hover of the content node (and to hide it again when the content is no longer being hovered). By default this is true.

setTextback to summary
public final void setText(String text)

Specifies the text to display over top of the content.

showOnHoverPropertyback to summary
public final BooleanProperty showOnHoverProperty()
Returns:BooleanProperty

A BooleanProperty representing whether the overlay on hover of the content node is showing.

textPropertyback to summary
public final StringProperty textProperty()
Returns:StringProperty

A StringProperty representing the text displayed over top of the content.