@landen.nienow
Вы можете добавить CSS в вашу JavaFX приложение с помощью нескольких различных способов.
1 2 3 4 5 6 7 8 9 10 11 |
<?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.Button?> <?import javafx.scene.layout.StackPane?> <StackPane xmlns:fx="http://javafx.com/fxml/1" fx:id="root"> <stylesheets> <URL value="style.css" /> </stylesheets> <Button fx:id="button" text="Click me!" /> </StackPane> |
1 2 3 4 |
StackPane root = new StackPane(); root.getStylesheets().add("style.css"); Button button = new Button("Click me!"); root.getChildren().add(button); |
1 2 3 4 5 6 |
<?xml version="1.0" encoding="UTF-8"?> <javafx-applications xmlns="http://javafx.com/javafx/8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://javafx.com/javafx/8 http://javafx.com/schema/javafx-application/8.0.0-SNAPSHOT.xsd"> <resources> <stylesheet>file:style.css</stylesheet> </resources> </javafx-applications> |
1 2 |
import javafx.application.Application; import j |
@landen.nienow
avafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage;
@Import("style.css") public class Main extends Application {
1 2 3 4 5 6 7 8 9 10 |
public void start(Stage stage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("main.fxml")); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } |
}