2016-03-15 82 views
0

對於Java學校項目,我希望有一張桌子,您可以選擇一個項目,然後在新窗口中顯示。在該窗口中,您可以更改組合框等。我唯一的問題是,我不知道如何選擇我需要的組合框的項目。所有的ComboBoxItems都是對象,我不知道如何處理這個。只選擇項目的一部分的組合框項目

我ComboBoxItem看起來是這樣的:

學徒[人=人,DB ID:9,卡帕卡帕,Kappastrasse 21, CityID:4521,[email protected],idpersonen = 9, vertragsstart = 2020年1月2日,ausbildungsct = 2,ID = 6]

現在,我的問題是,我該如何選擇其中ID = 6,所有的事情,我發現需要整個對象的ComboBoxitem選擇一個特殊的項目。你們會如何解決這個問題?

祝你好運,謝謝你的幫助。 Bono

回答

0

我所要做的只是一個非常簡單的一個for和一個if。

int trys = 0; 
    while (0 == apprenticeComboBoxZeugnis.getItemCount() && trys < 10000) { 
    System.out.println(apprenticeComboBoxZeugnis.getItemCount()); 
    for (int i = 0; i < apprenticeComboBoxZeugnis.getItemCount(); i++) { 
     apprenticeComboBoxZeugnis.setSelectedIndex(i - 1); 
     int spacko = getApprenticeCombo(); 
     if (spacko == lehrlingsid) { 
     TableFilterListenerZeugnis tableFilterListenerZeugnis = new TableFilterListenerZeugnis(
      this); 
     tableFilterListenerZeugnis.updateNoten(); 
     break; 
     } 
    } 
    trys++; 
    } 

這首先改掉,直到對象的數量不= 0,即着眼於每一個對象後,削減了ID與getApprenticeCombo(),它與我的ID我有媒體鏈接比較。如果它們匹配,就會爆發並完成它。

相關問題