JFXtras / jfxtras-styles

Java, JavaFX themes or look and feels. Currently contains JMetro theme.
https://pixelduke.com/java-javafx-theme-jmetro/
642 stars 144 forks source link

Wrong Spinner text color inside TabPane #227

Open runiter opened 1 year ago

runiter commented 1 year ago

I came across a very specific scenario which causes Spinner text color to change into wrong color.

Here is the code to reproduce it:

public class Test extends Application {
    public void start(Stage stage) throws IOException {
        TabPane tabPane1 = new TabPane(new Tab("Tab1", new Spinner<>(0, 10, 5)));
        TabPane tabPane2 = new TabPane(new Tab("Tab1"), new Tab("Tab2"));
        VBox vbox = new VBox(tabPane1, tabPane2);
        Scene scene = new Scene(vbox);
        stage.setScene(scene);
        new JMetro(scene, Style.DARK);
        stage.show();
    }
}

If you run the above code, initially it shows correct color for spinner text (white):

image

But if you click on Tab2 then the color of spinner text changes from white to black:

image

dukke commented 1 year ago

HI Saeid,

I've spent quite some time with this but still haven't figured exactly what's wrong.

So far, I've discovered that this only happens when the Spinner control is inside a TabPane.

runiter commented 1 year ago

Hi Pedro, Yeah it's a tough one. When I debugged it I noticed that a method is called that keeps setting the text color to default hence overriding your css value. Not sure why that is only triggered when spinner is inside TabPane though!

dukke commented 1 year ago

@runiter Can you do the following: Create the same simple application you posted here and don't use JMetro. Instead, use a custom stylesheet that simply changes the text color of spinners to a specific color (say red or some other color).

Something like:

.spinner > .text-field {
    -fx-text-fill: red;
}

See if the color still changes to black like it's changing in your example... If it does, then it means it is an issue with javafx and not JMetro and we need to submit an issue to the javafx team (I suspect this is the case).

dukke commented 1 year ago

... tell me your findings when you do :)

runiter commented 1 year ago

Sorry for delay. I tried the css your suggest and nope it did not change color to red. The problem with black text persists. Looks like the css gets overriden for jspinner.