All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.palexdev.mfxcomponents.window.MFXPlainContent Maven / Gradle / Ivy

There is a newer version: 11.26.0
Show newest version
package io.github.palexdev.mfxcomponents.window;

import io.github.palexdev.mfxcomponents.controls.base.MFXStyleable;
import io.github.palexdev.mfxcore.controls.Label;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;

import java.util.List;

/**
 * A simple pane to display some text. Ideal for simple tooltips.
 */
public class MFXPlainContent extends StackPane implements MFXStyleable {
    //================================================================================
    // Properties
    //================================================================================
    private final StringProperty text = new SimpleStringProperty();

    //================================================================================
    // Constructors
    //================================================================================
    public MFXPlainContent() {
        this("");
    }

    public MFXPlainContent(String text) {
        setText(text);

        Label lText = new Label();
        lText.textProperty().bind(textProperty());

        getStyleClass().setAll(defaultStyleClasses());
        super.getChildren().add(lText);
    }

    //================================================================================
    // Overridden Methods
    //================================================================================
    @Override
    public ObservableList getChildren() {
        return getChildrenUnmodifiable();
    }

    @Override
    public List defaultStyleClasses() {
        return List.of("plain");
    }

    //================================================================================
    // Getters/Setters
    //================================================================================
    public String getText() {
        return text.get();
    }

    /**
     * Specifies the text to display.
     */
    public StringProperty textProperty() {
        return text;
    }

    public void setText(String text) {
        this.text.set(text);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy