#How do I stop my button from disappearing when I use both a stylesheet and a custom button skin?

1 messages · Page 1 of 1 (latest)

floral breachBOT
#

<@&987246487241105418> please have a look, thanks.

latent grotto
#
package me.jason.badddos.skins;


import javafx.animation.FadeTransition;
import javafx.scene.control.Button;
import javafx.scene.control.SkinBase;
import javafx.scene.text.Font;
import javafx.util.Duration;




public class ButtonSkin extends SkinBase<Button> {




    public ButtonSkin(Button button) {
        super(button);

        // Set Properties
        button.setStyle("-fx-font-size: 2em;");
        button.setStyle("-fx-font-weight: 800;");

        final FadeTransition fadeIn = new FadeTransition(Duration.millis(100));
        fadeIn.setNode(getSkinnable());
        fadeIn.setToValue(1);
        getSkinnable().setOnMouseEntered(e -> fadeIn.playFromStart());

        final FadeTransition fadeOut = new FadeTransition(Duration.millis(100));
        fadeOut.setNode(getSkinnable());
        fadeOut.setToValue(0.5);
        getSkinnable().setOnMouseExited(e -> fadeOut.playFromStart());
    }




}
```This is my button skin that I made
#
* {
    -fx-background-color: black;
    -fx-fill: red;
    -fx-font-size: 2em;
}

#ip_input {
    -fx-alignment: center;
}
```This is the scene's css
#
package me.jason.badddos;

import javafx.animation.Animation;
import javafx.animation.FadeTransition;
import javafx.animation.PauseTransition;
import javafx.animation.Transition;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import me.jason.badddos.skins.ButtonSkin;


public class Home_Controller {




    @FXML
    private Label label;
    @FXML
    private Button ddosBtn;


    @FXML
    // Initialization Function
    protected void initialize() {
        ButtonSkin skin = new ButtonSkin(ddosBtn);
        ddosBtn.setSkin(skin);
    }


    @FXML
    protected void ddos_btn_click() {
        label.setText("Beginning DDOS...");
    }




}
```This is the controller.java for the scene
#

I have a custom button skin that I made for my button, but when I apply it to the button, the button disappears. I think the css and the skin is conflicting, because when I remove all the css, the button is fine, and when I remove the button skin, the button is also fine.

Maybe there's a way to override the style for the button when using the custom skin?

#

_ _

#

_ _

#

this isn't gonna be a function program, just a gui for my learning of javafx

latent grotto
#

@vale cave do you have thy answers