SceneBuilderと3つのボタンと2つのImageViewで小さなFXMLファイルを作成しました。SceneBuilderで画像を表示
は、私は何をしたいです:NEXT
ボタン、ディスプレイ2枚の他の画像を押すと
- が開始
- でアプリとディスプレイ2枚の画像を実行します。
私の問題は、イメージをスウィージングするのではなく、シーンビルダによって作成されたImageViewとして表示することです。
ここに私のコントローラクラスです:
public class Controller {
private Button Next; //1st button
private Button J2inc; //2nd button
private Button J1inc; /3rd button
private ImageView Img1;
private ImageView Img2;
void Inc2(ActionEvent event) {
//nothing for the moment
}
void Inc1(ActionEvent event) {
//nothing for the moment
}
void Nextimg(ActionEvent event) {
//nothing for the moment
}
}
そして、私のstart
方法:
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("Css.fxml"));
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.setTitle("P ");
primaryStage.show();
}
私はImageView img1
を初期化する方法がわからないので、それが何かをロードします。
は私だけImageViewの行を追加しますので、ここではFXMLを追加できませんでした:
<ImageView fx:id="Img1" fitHeight="750.0" fitWidth="450.0" layoutY="22.0" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="50.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="450.0" AnchorPane.topAnchor="25.0" />
「FXMLを追加できませんでした」とは何ですか?コードの書式設定方法を知りたい場合は、[this](http://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks)を読んでください。また、[適切な命名規則](https://en.wikipedia.org/wiki/Naming_convention_(programming)#Java)を使用すると、人々があなたのJavaコードを読むのに役立つことに注意してください(正しく強調表示されます)。 –
はい、それは私が意味していた、私は再びそれを読むでしょう。 – Bouji