Hier ist der Code: < /p>
Code: Select all
public class Main extends Application {
@Override
public void start(Stage myStage) throws IOException {
myStage.setTitle("title");
myStage.setScene(getScene());
stage = myStage;
myStage.show();
}
public static void main(String[] args) {
launch();
}
private Scene getScene() {
List nodes = new ArrayList();
Image i1 = loadFromPath("... some path");
Image i2 = loadFromPath("... some other path");
Image i3 = loadFromPath("... again some other path");
ImageView v1 = new ImageView(i1);
ImageView v2 = new ImageView(i2);
ImageView v3 = new ImageView(i3);
v1.setTranslateX(100);
v1.setTranslateY(100);
v2.setTranslateX(320);
v2.setTranslateY(100);
v3.setTranslateX(540);
v3.setTranslateY(100);
nodes.add(v1);
nodes.add(v2);
nodes.add(v3);
VBox box = new VBox(nodes.toArray(new Node[0]));
box.setMinWidth(800);
box.setMaxWidth(800);
box.setMinHeight(400);
box.setMaxHeight(400);
return new Scene(box);
}
private Image loadFromPath(String path) {
FileInputStream input = null;
try {
input = new FileInputStream(path);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
return new Image(input);
}
}

When I use setLayoutX() and setLayoutY() instead of setTranslateX() and setTranslateY(),
the result is even worse:

Can someone please explain this result?