Ich bin neu in JavaFX, das ist mein Code. Diese Anwendung hat eine Schaltfläche, Wenn Sie auf die Schaltfläche klicken, öffnet sich ein neues Formular. Weiß jemand, wie man ein Bild in ein neues Formular einfügt?So importieren Sie Bilder in neuer Form
package javafxwindow;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
Pakete, die ich verwendet habe. Die Klasse JavaFXWindow.
public class JavaFXWindow extends Application {
@Override
public void start(Stage primaryStage) {
Button btn = new Button();
btn.setText("Open a New Window");
btn.setOnAction((ActionEvent event) -> {
Label secondLabel = new Label("Hello");
StackPane secondaryLayout = new StackPane();
secondaryLayout.getChildren().add(secondLabel);
Scene secondScene = new Scene(secondaryLayout, 200, 100);
Stage secondStage = new Stage();
secondStage.setTitle("New Stage");
secondStage.setScene(secondScene);
secondStage.show();
});
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("java-buddy.blogspot.com");
primaryStage.setScene(scene);
primaryStage.show();
primaryStage.setOnCloseRequest(e -> Platform.exit());
}
public static void main(String[] args) {
launch(args);
}
}
Wie füge ich 4 Bilder in neuer Form hinzu? Vielen Dank. –
"Pfad" ist irreführend. Es sollte eine *** URL *** sein! @somiludak Wie wäre es mit etwas selbst ausprobieren? Warnung: Sie können dabei etwas Erfahrung sammeln ... – fabian