我对编程非常陌生,所以我需要帮助解决这个问题。 我想做一个'#lab; testLabel"并把它放在不同的位置。这可能吗?
@Override
public void initialize(URL url, ResourceBundle rb)
{
if(student.getBereich equals ausgewählter Bereich)
for (i=0; i<=3; i++){
try {
ArrayList<Student> studiList = readJSON();
for (Student student : studiList) {
int j = 115;
testLabel.setText(student.getVorname()+" "+student.getNachname());
testLabel.setLayoutX(175);
testLabel.setLayoutY(j);
testLabel.setVisible(true);
java.util.Collections.sort(studiList, Collator.getInstance());
}
//i<3 in anz_studenten ändern!!
for (i=0; i<3; i++){
for (Student student : studiList) {
Image img = new Image(student.getBild());
testImage.setImage(img);
testImage.setLayoutX(15);
testImage.setLayoutY(30);
testImage.setFitHeight(190);
testImage.setFitWidth(160);
testImage.setVisible(true);
java.util.Collections.sort(studiList, Collator.getInstance());
}
}
} catch(Exception e){
e.printStackTrace();
}
答案 0 :(得分:0)
是的,你可以在这里添加多个标签
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class MainNoFXML extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
VBox vBox = new VBox();
vBox.setAlignment(Pos.CENTER);
for (int i = 0; i < 1000; i++) {
Label label = new Label("Label Number"+i);
vBox.getChildren().add(label);
}
Scene scene = new Scene(vBox);
Stage stage = new Stage();
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}