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

de.jensd.fx.glyphs.control.GlyphCheckBox Maven / Gradle / Ivy

Go to download

A Speedment bundle that shades all dependencies into one jar. This is useful when deploying an application on a server.

There is a newer version: 3.1.6
Show newest version
package de.jensd.fx.glyphs.control;

import de.jensd.fx.glyphs.GlyphIcon;
import de.jensd.fx.glyphs.control.skin.GlyphCheckBoxSkin;

import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Skin;

/**
 * @author Jens Deters ([email protected])
 */
public class GlyphCheckBox extends CheckBox {

    private ObjectProperty notSelectedIcon;
    private ObjectProperty selectedIcon;

    public GlyphCheckBox() {
        super("");
    }

    public GlyphCheckBox(GlyphIcon notSelectedIcon, GlyphIcon selectedIcon, String text) {
        super(text);
        setNotSelectedIcon(notSelectedIcon);
        setSelectedIcon(selectedIcon);
    }

    @Override
    protected Skin createDefaultSkin() {
        return new GlyphCheckBoxSkin(this);
    }

    public ObjectProperty notSelectedIconProperty() {
        if (notSelectedIcon == null) {
            notSelectedIcon = new SimpleObjectProperty(new FontAwesomeIconView(FontAwesomeIcon.TOGGLE_OFF));
        }
        return notSelectedIcon;
    }

    public GlyphIcon getNotSelectedIcon() {
        return notSelectedIconProperty().get();
    }

    public void setNotSelectedIcon(GlyphIcon icon) {
        notSelectedIconProperty().set(icon);
    }

    public ObjectProperty selectedIconProperty() {
        if (selectedIcon == null) {
            selectedIcon = new SimpleObjectProperty(new FontAwesomeIconView(FontAwesomeIcon.TOGGLE_ON));
        }
        return selectedIcon;
    }

    public GlyphIcon getSelectedIcon() {
        return selectedIconProperty().get();
    }

    public void setSelectedIcon(GlyphIcon icon) {
        selectedIconProperty().set(icon);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy