Package com.aquafx_project.controls.skin

Source Code of com.aquafx_project.controls.skin.AquaChoiceBoxSkin

package com.aquafx_project.controls.skin;

import javafx.scene.control.ChoiceBox;

import com.aquafx_project.controls.skin.effects.FocusBorder;
import com.aquafx_project.controls.skin.effects.Shadow;
import com.sun.javafx.scene.control.skin.ChoiceBoxSkin;


public class AquaChoiceBoxSkin<T> extends ChoiceBoxSkin<T> implements AquaSkin{

    public AquaChoiceBoxSkin(ChoiceBox<T> choiceBox) {
        super(choiceBox);

        registerChangeListener(choiceBox.focusedProperty(), "FOCUSED");
        registerChangeListener(choiceBox.disabledProperty(), "DISABLED");

        if (getSkinnable().isFocused()) {
            setFocusBorder();
        } else if(!getSkinnable().isFocused() && !getSkinnable().isDisabled()) {
            setDropShadow();
        }
    }

    private void setFocusBorder() {
        getSkinnable().setEffect(new FocusBorder());
    }
   
    private void setDropShadow() {
        getSkinnable().setEffect(new Shadow(false));
    }

    @Override protected void handleControlPropertyChanged(String p) {
        super.handleControlPropertyChanged(p);

        if (p == "FOCUSED") {
            if (getSkinnable().isFocused()) {
                setFocusBorder();
            } else {
                setDropShadow();
            }
        }
        if (p == "DISABLED") {
            if (getSkinnable().isDisabled()) {
                getSkinnable().setEffect(null);
            } else {
                setDropShadow();
            }
        }
    }
}
TOP

Related Classes of com.aquafx_project.controls.skin.AquaChoiceBoxSkin

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.