public static void loadUser(String txtFieldName, String txtFeildPassword) throws FileNotFoundException {
File file = new File( "C:\\Users\\obiak\\Documents\\fall 2018\\application Programming\\JavaFX Workspace"
+ "\\obp937-lab5\\src\\main\\resources\\data\\users.csv" );
Scanner scan = new Scanner(file);
ArrayList<User> user = new ArrayList<>();
while( scan.hasNextLine() ) {
String line = scan.nextLine();
String [] token = line.split(",");
String name = token[0];
String pass = token[1];
String wood = token[2];
String core = token[3];
String length = token[4];// remember to change file back to 8.5 and ammend constructors also
String quality = token[5];
User newUser = new User(name, pass, wood, core, length, quality);
user.add(newUser);
}
scan.close();
System.out.println("I am here now");
}
}
这是获取用户信息以填充组合框的代码部分。它是在非控制器类中声明和定义的。代码获取用户信息没问题,然后将其传递给控制器类中定义的名为“loadUserBox”的方法。代码一直工作,直到需要将详细信息传递给控制器类方法。它不会失败,但只是不会填充组合框。我是否错误地调用了控制器方法?请帮忙解释谢谢。我正在使用场景构建器、JavaFX、FXML
public void loaduserBox(String wood, String core, String length, String quality) {
ObservableList<String> list = FXCollections.observableArrayList( wood, core, length, quality);
System.out.println("Whats wrong");
woodBox.getItems().clear();
woodBox.getItems().addAll(list);
}
//这部分代码接收信息来填充组合框。组合框已经在我所指的同一个控制器类中声明
PIPIONE
相关分类