1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| package fxmlsvg;
import java.io.IOException;
import java.net.URL;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Orientation;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws IOException {
final Button button = new Button();
button.setGraphic(new SVGNode(getClass().getResource("test.svg").toExternalForm()));
final StackPane top = new StackPane(button);
final SplitPane root = new SplitPane(top);
root.setOrientation(Orientation.HORIZONTAL);
final URL fxmlURL = getClass().getResource("test.fxml");
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL);
final Parent bottom = fxmlLoader.load();
root.getItems().add(bottom);
Scene scene = new Scene(root, 500, 500);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
Platform.runLater(() -> root.setDividerPositions(0.5));
}
public static void main(String[] args) {
launch(args);
}
} |
Partager