1
我已經創造了FXML列表視圖與「lwAllUserGrp」的ID。我可以使用該ID和下面的函數來填充它:我的函數不能被調用在JavaFX
public void populateAllUserList() {
lwAllUserGrp.getItems().clear();
///////////////////////////////////////////////
String filter = txtSearch.getText();
String Query = "Select user_name, user_login_name, user_state from dm_user where r_is_group = 0 and user_state = 0 and (user_name not like 'dm%' and user_name not like 'svc%' and user_name not like 'lexo%') order by user_name";
ArrayList<String> AllUser = GetDataWithDql(_session, Query, "user_name");
for (String x : AllUser) {
if (x.toLowerCase().contains(filter.toLowerCase())){
lwAllUserGrp.getItems().add(x);
}
}
}
但是,當我加入以下函數查看哪一行被選中:
public void selectedItemFromListView(){
// System.out.println("blabla");
selected = lwAllUserGrp.getSelectionModel().getSelectedItem();
// System.out.println(selected);
String Query = "select user_name , user_state , user_address, user_login_name , user_web_page from dm_user where user_name ='@aclname'";
Query = Query.replace("@aclname",selected);
ArrayList<User> allUserNames = GetDataWithDqlpro(_session, Query, "user_name","user_address","user_state","user_login_name","user_web_page");
for (int i = 0 ; i < allUserNames.size() ; i++){
if (selected.compareToIgnoreCase(allUserNames.get(i).getUsername()) == 0){
username.setText(selected);
login_Name.setText(allUserNames.get(i).getuserLoginName());
state.setText(allUserNames.get(i).getState());
address.setText(allUserNames.get(i).getAddress());
WP.setText(allUserNames.get(i).getuserWP());
}
}
}
我的函數根本不會被調用?任何人都知道原因?
您是否使用過'System.out.println'來驗證函數沒有被調用?如果沒有,是否有可能allUserNames是空的/該循環中的比較沒有成功,所以它只出現*它沒有被調用?另外,顯而易見的問題是:你如何調用這個函數?它不會自稱;你必須從某個地方或例如註冊一個監聽器。 –
@JasonC,以確保函數被調用或不是我添加System.out.println(「blabla」);在函數的開頭,但沒有找到輸出:( –
顯示代碼,你實際上調用函數 –