有人可以告诉我为什么下面示例中的-fx-text-fill无法更改字体颜色吗?-fx-中风也是我尝试过的。谢谢!
Java文件:
package SimpleTextFromCSS;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class Main extends Application
{
@Override
public void start(Stage primaryStage)
{
GridPane rootGP = new GridPane();
Label centerText = new Label("Sample text.");
rootGP.getChildren().add(centerText);
Scene scene = new Scene(rootGP,1200,800);
scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
primaryStage.setScene(mainScene);
primaryStage.show();
}
}
public static void main(String[] args)
{
launch(args);
}
}
Run Code Online (Sandbox Code Playgroud)
CSS:
.root{
-fx-font-family: "Broadway";
-fx-font-size: 50pt;
-fx-text-fill: blue;
}
Run Code Online (Sandbox Code Playgroud)