I am new to CSS and have the following CSS style defined for the button, with the id and the custom style is applied, but not the hover and pressed effect.
#bevel-grey {
-fx-background-color: linear-gradient(#f2f2f2, #d6d6d6), linear-gradient(#fcfcfc 0%, #d9d9d9 20%, #d6d6d6 100%), linear-gradient(#dddddd 0%, #f6f6f6 50%);
-fx-background-radius: 8, 7, 6;
-fx-background-insets: 0, 1, 2;
-fx-text-fill: black;
-fx-effect: dropshadow( three-pass-box, rgba(0, 0, 0, 0.6), 5, 0.0, 0, 1);
}
#bevel-grey:hover {
-fx-background-color: #981100;
}
#bevel-grey:pressed {
-fx-background-color: #235891;
}
Replacing #bevel-grey
with .button
does not give me the custom effects, but works for hover and pressed. How can I get it working along with the custom style defined?
UPDATE
The Main code, to reproduce the problem.
package application;
import java.util.List;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;
public class Main extends Application
{
@Override
public void start(Stage primaryStage)
{
try
{
Pane p = new Pane();
Scene scene = new Scene(p,400,400);
Button b = new Button();
b.setId("bevel-grey");
b.getStylesheets().add(getClass().getResource("ButtonStyles.css").toExternalForm());
b.setLayoutX(150);
b.setLayoutY(300);
b.setPrefWidth(100);
b.setText("Start");
p.getChildren().add(b);
primaryStage.setScene(scene);
primaryStage.show();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}