2013-01-07 45 views
0

我已成立了像這樣的表:填充的JComboBox與SimpleTable數據

表角色:

super("ROLES", // Name 
      true, // Can insert 
      true, // Can modify 
      true, // Can delete 
      true, // Supports events 
      "system_table_data/roles.dat", // don't Journal to disk 
      1, // Read Access Level 
      1, // Write Access Level (controlled via GUI) 
      // Field Info 
      new Object[][] {// Key Name    Type   Read Write Insert Modify 
          {PK_FIELD, "ROLE_ID",   "ROLE_ID", YES, YES, NO,  NO}, // 0 BYTE 
          {NM_FIELD, "ROLE_NAME",  "STRING_80", YES, YES, YES, YES}, // 1 
          {NM_FIELD, "SHIFT_PATTERN_ID","SHIFT_PAT", YES, YES, YES, YES}, // 2 BYTE 
          {NM_FIELD, "START_DATE",  "CS_TIME", YES, YES, YES, YES}, // 3 
          } 
      ); 

錶轉移模式:

super("PATTERNS", // Name 
      true, // Can insert 
      true, // Can modify 
      true, // Can delete 
      true, // Supports events 
      "system_table_data/patterns.dat", // don't Journal to diskmember_hna 
      1, // Read Access Level 
      1, // Write Access Level (controlled via GUI) 
      // Field Info 
      new Object[][] {// Key Name    Type   Read Write Insert Modify 
          {PK_FIELD, "NAME_ID", "PATNAME_ID",  YES, YES, NO,  NO}, // 0 
          {NM_FIELD, "NAME",  "STRING_80",  YES, YES, NO, YES}, // 1 
          } 
      ); 

我使用JTables並彈出對話框,其中包含字段以填充表格並將信息存儲在表格中,例如兩個。

它全部位於選項卡窗格中:角色選項卡和Shift模式選項卡。

在「角色」窗格中,對話框中有一個組合框,應該使用Shift Patterns的名稱填充該組合框,我想知道如何執行此操作?

+0

對不起,從你的問題,a.m.描述,DYM每個JComboBoxes有不同的模型,數據,項目和結構e.i. ???? – mKorbel

+0

有一個使用JPA的例子[這裏](http://stackoverflow.com/a/2531942/230513)。 – trashgod

回答

1

而不是具有直Object[]爲什麼沒有像Pattern[]toString()方法,然後自定義類剛創建與Pattern[]一個JComboBox(Object[])? (API Link) 然後,它會使用toString()方法顯示圖案文本作爲選擇,您可以獲取所選的Pattern並隨心所欲地執行任何操作。